From 288c594f278da88cb85ac419711815783dcab469 Mon Sep 17 00:00:00 2001 From: Xeltica Date: Wed, 16 Feb 2022 01:02:24 +0900 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=E4=B8=A1=E6=96=B9=E3=80=8D=E3=82=AA?= =?UTF-8?q?=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++ migration/1644940446672-alertModeBoth.ts | 24 ++++++++++++++++ src/backend/services/send-alert.ts | 6 ++++ src/common/types/alert-mode.ts | 1 + src/frontend/components/MisshaiPage.tsx | 36 +++++++++++------------- src/frontend/langs/ja-JP.json | 1 + 6 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 migration/1644940446672-alertModeBoth.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf10b3..3f53713 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.4.0 +* アラート通知方法に「両方」を追加 + ## 2.3.0 * 韓国語サポート * デザイン調整 diff --git a/migration/1644940446672-alertModeBoth.ts b/migration/1644940446672-alertModeBoth.ts new file mode 100644 index 0000000..98b97a5 --- /dev/null +++ b/migration/1644940446672-alertModeBoth.ts @@ -0,0 +1,24 @@ +import {MigrationInterface, QueryRunner} from 'typeorm'; + +export class alertModeBoth1644940446672 implements MigrationInterface { + name = 'alertModeBoth1644940446672' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query('ALTER TYPE "public"."user_alertmode_enum" RENAME TO "user_alertmode_enum_old"'); + await queryRunner.query('CREATE TYPE "user_alertmode_enum" AS ENUM(\'note\', \'notification\', \'both\', \'nothing\')'); + await queryRunner.query('ALTER TABLE "user" ALTER COLUMN "alertMode" DROP DEFAULT'); + await queryRunner.query('ALTER TABLE "user" ALTER COLUMN "alertMode" TYPE "user_alertmode_enum" USING "alertMode"::"text"::"user_alertmode_enum"'); + await queryRunner.query('ALTER TABLE "user" ALTER COLUMN "alertMode" SET DEFAULT \'notification\''); + await queryRunner.query('DROP TYPE "user_alertmode_enum_old"'); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query('CREATE TYPE "user_alertmode_enum_old" AS ENUM(\'note\', \'notification\', \'nothing\')'); + await queryRunner.query('ALTER TABLE "user" ALTER COLUMN "alertMode" DROP DEFAULT'); + await queryRunner.query('ALTER TABLE "user" ALTER COLUMN "alertMode" TYPE "user_alertmode_enum_old" USING "alertMode"::"text"::"user_alertmode_enum_old"'); + await queryRunner.query('ALTER TABLE "user" ALTER COLUMN "alertMode" SET DEFAULT \'notification\''); + await queryRunner.query('DROP TYPE "user_alertmode_enum"'); + await queryRunner.query('ALTER TYPE "user_alertmode_enum_old" RENAME TO "user_alertmode_enum"'); + } + +} diff --git a/src/backend/services/send-alert.ts b/src/backend/services/send-alert.ts index 9d02adb..737d71d 100644 --- a/src/backend/services/send-alert.ts +++ b/src/backend/services/send-alert.ts @@ -16,6 +16,12 @@ export const sendAlert = async (user: User) => { case 'notification': await sendNotificationAlert(text, user); break; + case 'both': + await Promise.all([ + sendNotificationAlert(text, user), + sendNoteAlert(text, user), + ]); + break; } }; diff --git a/src/common/types/alert-mode.ts b/src/common/types/alert-mode.ts index 3100831..f09d16c 100644 --- a/src/common/types/alert-mode.ts +++ b/src/common/types/alert-mode.ts @@ -1,6 +1,7 @@ export const alertModes = [ 'note', 'notification', + 'both', 'nothing' ] as const; diff --git a/src/frontend/components/MisshaiPage.tsx b/src/frontend/components/MisshaiPage.tsx index 02d02a7..2603af3 100644 --- a/src/frontend/components/MisshaiPage.tsx +++ b/src/frontend/components/MisshaiPage.tsx @@ -197,13 +197,6 @@ export const MisshaiPage: React.VFC = () => { -
-
-

{t('_missHai.ranking')}

- - {limit && } -
-
@@ -248,29 +241,34 @@ export const MisshaiPage: React.VFC = () => {
+
+
+

{t('_missHai.ranking')}

+ + {limit && } +
+

{t('alertMode')}

- { - alertModes.map((mode) => ( - - )) - } + { alertModes.map((mode) => ( + + ))}
- { draft.alertMode === 'notification' && ( + { (draft.alertMode === 'notification' || draft.alertMode === 'both') && (
{t('_alertMode.notificationWarning')}
)} - { draft.alertMode === 'note' && ( + { (draft.alertMode === 'note' || draft.alertMode === 'both') && ( <>

{t('visibility')}

diff --git a/src/frontend/langs/ja-JP.json b/src/frontend/langs/ja-JP.json index b3f682a..3e56a3f 100644 --- a/src/frontend/langs/ja-JP.json +++ b/src/frontend/langs/ja-JP.json @@ -99,6 +99,7 @@ "_alertMode": { "note": "自動的にノートを投稿", "notification": "Misskeyに通知(標準)", + "both": "両方", "nothing": "通知しない", "notificationWarning": "「Misskey に通知」オプションは古いMisskeyでは動作しません。" },