Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Announcement Image URL cannot be deleted during creation | アナウンスメントを作成ときにWebUIフォームの画像URLを後悔できない #14976

Open
1 task done
eternal-flame-AD opened this issue Nov 16, 2024 · 0 comments · May be fixed by #14990
Labels
🐛Bug Unexpected behavior packages/backend Server side specific issue/PR

Comments

@eternal-flame-AD
Copy link
Contributor

💡 Summary

タイトル通りです

await this.announcementService.update(announcement, {
updatedAt: new Date(),
title: ps.title,
text: ps.text,
/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- 空の文字列の場合、nullを渡すようにするため */
imageUrl: ps.imageUrl || null,
display: ps.display,
icon: ps.icon,
forExistingUsers: ps.forExistingUsers,
silence: ps.silence,
needConfirmationToRead: ps.needConfirmationToRead,
isActive: ps.isActive,
}, me);

const { raw, packed } = await this.announcementService.create({
updatedAt: null,
title: ps.title,
text: ps.text,
imageUrl: ps.imageUrl,
icon: ps.icon,
display: ps.display,
forExistingUsers: ps.forExistingUsers,
silence: ps.silence,
needConfirmationToRead: ps.needConfirmationToRead,
userId: ps.userId,

Proposed fix

https://forge.yumechi.jp/yume/yumechi-no-kuni/commit/13e50cd8d9e1f8e2d91c0ca387206b904c495fe5

diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts
index 2dae1df87d..b8bfda73a4 100644
--- a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts
+++ b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts
@@ -55,7 +55,7 @@ export const paramDef = {
 	properties: {
 		title: { type: 'string', minLength: 1 },
 		text: { type: 'string', minLength: 1 },
-		imageUrl: { type: 'string', nullable: true, minLength: 1 },
+		imageUrl: { type: 'string', nullable: true, minLength: 0 },
 		icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'], default: 'info' },
 		display: { type: 'string', enum: ['normal', 'banner', 'dialog'], default: 'normal' },
 		forExistingUsers: { type: 'boolean', default: false },
@@ -76,7 +76,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
 				updatedAt: null,
 				title: ps.title,
 				text: ps.text,
-				imageUrl: ps.imageUrl,
+				/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- 空の文字列の場合、nullを渡すようにするため */
+				imageUrl: ps.imageUrl || null,
 				icon: ps.icon,
 				display: ps.display,
 				forExistingUsers: ps.forExistingUsers,

🥰 Expected Behavior

  1. See "Steps to Reproduce"
  2. 200 OK

🤬 Actual Behavior

  1. See "Steps to Reproduce"
  2. 400 Bad Request

📝 Steps to Reproduce

  1. https://misskey-hub.net/en/mi-web/?path=/admin/announcements
  2. 追加
  3. title <- "Test"
  4. text <- "Text"
  5. 画像URL <- "AAA"
  6. 画像URL <- Backspace *3
  7. 保存

💻 Frontend Environment

Not a frontend problem

🛰 Backend Environment (for server admin)

* Installation Method or Hosting Service: Docker-compose.yml (https://forge.yumechi.jp/yume/yumechi-no-kuni/src/branch/develop/compose_example.yml)
* Misskey: [2024.11.0-yumechinokuni.4p1](https://forge.yumechi.jp/yume/yumechi-no-kuni/src/tag/2024.11.0-yumechinokuni.4p1) (tracking misskey-dev#develop)
* OS and Architecture: Arch Linux x86_64

Do you want to address this bug yourself?

  • Yes, I will patch the bug myself and send a pull request
@eternal-flame-AD eternal-flame-AD added the ⚠️bug? This might be a bug label Nov 16, 2024
@kakkokari-gtyih kakkokari-gtyih added 🐛Bug Unexpected behavior packages/backend Server side specific issue/PR and removed ⚠️bug? This might be a bug labels Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛Bug Unexpected behavior packages/backend Server side specific issue/PR
Projects
None yet
2 participants