From c2ddb649f841c48bca91db3fdee1e95f79e8bdf4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 Nov 2023 09:04:38 +0900 Subject: [PATCH] =?UTF-8?q?enhance:=20=E9=9D=9E=E9=80=9A=E7=9F=A5=E3=81=AA?= =?UTF-8?q?=E3=81=8A=E7=9F=A5=E3=82=89=E3=81=9B=E3=82=92=E4=BD=9C=E6=88=90?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + locales/index.d.ts | 2 ++ locales/ja-JP.yml | 2 ++ .../1699141698112-announcement-silence.js | 18 ++++++++++++++++++ .../backend/src/core/AnnouncementService.ts | 4 ++++ packages/backend/src/models/Announcement.ts | 6 ++++++ .../endpoints/admin/announcements/create.ts | 2 ++ .../api/endpoints/admin/announcements/list.ts | 1 + .../endpoints/admin/announcements/update.ts | 2 ++ .../frontend/src/pages/admin/announcements.vue | 4 ++++ packages/frontend/src/pages/announcements.vue | 4 ++-- 11 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 packages/backend/migration/1699141698112-announcement-silence.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 7890408cd6..e8b845974c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - ユーザーが誤ったメールアドレスを入力した場合に招待コードが失効してしまう問題が解消されます。 - Enhance: すでにフォローしたすべての人の返信をTLに追加できるように - Enhance: 未読の通知数を表示できるように +- Enhance: 通知されず、確認の必要もないお知らせ(silence)を作成可能になりました - Enhance: ローカリゼーションの更新 - Enhance: 依存関係の更新 - Change: CWを使用する場合、注釈を空にすることは許可されなくなりました diff --git a/locales/index.d.ts b/locales/index.d.ts index aedaaa9f7c..fc6653b05b 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -1172,6 +1172,8 @@ export interface Locale { "readConfirmText": string; "shouldNotBeUsedToPresentPermanentInfo": string; "dialogAnnouncementUxWarn": string; + "silence": string; + "silenceDescription": string; }; "_initialAccountSetting": { "accountCreated": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 6ecebfc393..67a57f994c 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1170,6 +1170,8 @@ _announcement: readConfirmText: "「{title}」の内容を読み、既読にします。" shouldNotBeUsedToPresentPermanentInfo: "特に新規ユーザーのUXを損ねる可能性が高いため、ストック情報ではなくフロー情報の掲示にお知らせを使用することを推奨します。" dialogAnnouncementUxWarn: "ダイアログ形式のお知らせが同時に2つ以上ある場合、UXに悪影響を及ぼす可能性が非常に高いため、使用は慎重に行うことを推奨します。" + silence: "非通知" + silenceDescription: "オンにすると、このお知らせは通知されず、既読にする必要もなくなります。" _initialAccountSetting: accountCreated: "アカウントの作成が完了しました!" diff --git a/packages/backend/migration/1699141698112-announcement-silence.js b/packages/backend/migration/1699141698112-announcement-silence.js new file mode 100644 index 0000000000..eef9b076fc --- /dev/null +++ b/packages/backend/migration/1699141698112-announcement-silence.js @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class AnnouncementSilence1699141698112 { + name = 'AnnouncementSilence1699141698112' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "announcement" ADD "silence" boolean NOT NULL DEFAULT false`); + await queryRunner.query(`CREATE INDEX "IDX_7b8d9225168e962f94ea517e00" ON "announcement" ("silence") `); + } + + async down(queryRunner) { + await queryRunner.query(`DROP INDEX "public"."IDX_7b8d9225168e962f94ea517e00"`); + await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "silence"`); + } +} diff --git a/packages/backend/src/core/AnnouncementService.ts b/packages/backend/src/core/AnnouncementService.ts index ec1a082d78..8c348e595d 100644 --- a/packages/backend/src/core/AnnouncementService.ts +++ b/packages/backend/src/core/AnnouncementService.ts @@ -47,6 +47,7 @@ export class AnnouncementService { const q = this.announcementsRepository.createQueryBuilder('announcement') .where('announcement.isActive = true') + .andWhere('announcement.silence = false') .andWhere(new Brackets(qb => { qb.orWhere('announcement.userId = :userId', { userId: user.id }); qb.orWhere('announcement.userId IS NULL'); @@ -73,6 +74,7 @@ export class AnnouncementService { icon: values.icon, display: values.display, forExistingUsers: values.forExistingUsers, + silence: values.silence, needConfirmationToRead: values.needConfirmationToRead, userId: values.userId, }).then(x => this.announcementsRepository.findOneByOrFail(x.identifiers[0])); @@ -124,6 +126,7 @@ export class AnnouncementService { display: values.display, icon: values.icon, forExistingUsers: values.forExistingUsers, + silence: values.silence, needConfirmationToRead: values.needConfirmationToRead, isActive: values.isActive, }); @@ -210,6 +213,7 @@ export class AnnouncementService { icon: announcement.icon, display: announcement.display, needConfirmationToRead: announcement.needConfirmationToRead, + silence: announcement.silence, forYou: announcement.userId === me?.id, isRead: reads.some(read => read.announcementId === announcement.id), })); diff --git a/packages/backend/src/models/Announcement.ts b/packages/backend/src/models/Announcement.ts index 05d5a086f1..8f8be88fed 100644 --- a/packages/backend/src/models/Announcement.ts +++ b/packages/backend/src/models/Announcement.ts @@ -66,6 +66,12 @@ export class MiAnnouncement { }) public forExistingUsers: boolean; + @Index() + @Column('boolean', { + default: false, + }) + public silence: boolean; + @Index() @Column({ ...id(), 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 253a29cf5a..69c31a05eb 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/create.ts @@ -58,6 +58,7 @@ export const paramDef = { icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'], default: 'info' }, display: { type: 'string', enum: ['normal', 'banner', 'dialog'], default: 'normal' }, forExistingUsers: { type: 'boolean', default: false }, + silence: { type: 'boolean', default: false }, needConfirmationToRead: { type: 'boolean', default: false }, userId: { type: 'string', format: 'misskey:id', nullable: true, default: null }, }, @@ -78,6 +79,7 @@ export default class extends Endpoint { // eslint- icon: ps.icon, display: ps.display, forExistingUsers: ps.forExistingUsers, + silence: ps.silence, needConfirmationToRead: ps.needConfirmationToRead, userId: ps.userId, }, me); diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts index 0bda61a361..9630299a6e 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/list.ts @@ -114,6 +114,7 @@ export default class extends Endpoint { // eslint- display: announcement.display, isActive: announcement.isActive, forExistingUsers: announcement.forExistingUsers, + silence: announcement.silence, needConfirmationToRead: announcement.needConfirmationToRead, userId: announcement.userId, reads: reads.get(announcement)!, diff --git a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts index d36590c264..717866aead 100644 --- a/packages/backend/src/server/api/endpoints/admin/announcements/update.ts +++ b/packages/backend/src/server/api/endpoints/admin/announcements/update.ts @@ -35,6 +35,7 @@ export const paramDef = { icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'] }, display: { type: 'string', enum: ['normal', 'banner', 'dialog'] }, forExistingUsers: { type: 'boolean' }, + silence: { type: 'boolean' }, needConfirmationToRead: { type: 'boolean' }, isActive: { type: 'boolean' }, }, @@ -63,6 +64,7 @@ export default class extends Endpoint { // eslint- display: ps.display, icon: ps.icon, forExistingUsers: ps.forExistingUsers, + silence: ps.silence, needConfirmationToRead: ps.needConfirmationToRead, isActive: ps.isActive, }, me); diff --git a/packages/frontend/src/pages/admin/announcements.vue b/packages/frontend/src/pages/admin/announcements.vue index 36a67eba31..5785fb118c 100644 --- a/packages/frontend/src/pages/admin/announcements.vue +++ b/packages/frontend/src/pages/admin/announcements.vue @@ -48,6 +48,9 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts._announcement.forExistingUsers }} + + {{ i18n.ts._announcement.silence }} + {{ i18n.ts._announcement.needConfirmationToRead }} @@ -97,6 +100,7 @@ function add() { icon: 'info', display: 'normal', forExistingUsers: false, + silence: false, needConfirmationToRead: false, }); } diff --git a/packages/frontend/src/pages/announcements.vue b/packages/frontend/src/pages/announcements.vue index babac9d805..afc6a98281 100644 --- a/packages/frontend/src/pages/announcements.vue +++ b/packages/frontend/src/pages/announcements.vue @@ -13,7 +13,7 @@ SPDX-License-Identifier: AGPL-3.0-only
{{ i18n.ts.forYou }}
- 🆕 + 🆕 @@ -29,7 +29,7 @@ SPDX-License-Identifier: AGPL-3.0-only
-
+
{{ i18n.ts.gotIt }}