From 547da89c7db41506cfe6fd139fd5a2f86070ac75 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 6 Feb 2021 22:47:15 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=8A=E7=9F=A5=E3=82=89=E3=81=9B=E3=83=A1?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=82=92=E5=8F=97=E3=81=91=E5=8F=96=E3=82=8B?= =?UTF-8?q?=E3=81=8B=E3=81=A9=E3=81=86=E3=81=8B=E3=81=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 1 + migration/1612619156584-announcement-email.ts | 14 ++++++++++++++ src/client/pages/settings/email.vue | 12 +++++++++++- src/models/entities/user-profile.ts | 5 +++++ src/models/repositories/user.ts | 1 + src/server/api/endpoints/i/update.ts | 5 +++++ 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 migration/1612619156584-announcement-email.ts diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 3f8542dfd0..5a7272b480 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -700,6 +700,7 @@ capacity: "容量" inUse: "使用中" editCode: "コードを編集" apply: "適用" +receiveAnnouncementFromInstance: "インスタンスからのお知らせを受け取る" _plugin: install: "プラグインのインストール" diff --git a/migration/1612619156584-announcement-email.ts b/migration/1612619156584-announcement-email.ts new file mode 100644 index 0000000000..0371daf8fa --- /dev/null +++ b/migration/1612619156584-announcement-email.ts @@ -0,0 +1,14 @@ +import {MigrationInterface, QueryRunner} from "typeorm"; + +export class announcementEmail1612619156584 implements MigrationInterface { + name = 'announcementEmail1612619156584' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user_profile" ADD "receiveAnnouncementEmail" boolean NOT NULL DEFAULT true`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "receiveAnnouncementEmail"`); + } + +} diff --git a/src/client/pages/settings/email.vue b/src/client/pages/settings/email.vue index 830c041bad..5ccb79a41d 100644 --- a/src/client/pages/settings/email.vue +++ b/src/client/pages/settings/email.vue @@ -8,6 +8,10 @@ {{ $i.email || $ts.notSet }} + + + {{ $ts.receiveAnnouncementFromInstance }} + @@ -19,6 +23,7 @@ import FormButton from '@/components/form/button.vue'; import FormLink from '@/components/form/link.vue'; import FormBase from '@/components/form/base.vue'; import FormGroup from '@/components/form/group.vue'; +import FormSwitch from '@/components/form/switch.vue'; import * as os from '@/os'; export default defineComponent({ @@ -26,6 +31,7 @@ export default defineComponent({ FormBase, FormLink, FormButton, + FormSwitch, FormGroup, }, @@ -46,7 +52,11 @@ export default defineComponent({ }, methods: { - + onChangeReceiveAnnouncementEmail(v) { + os.api('i/update', { + receiveAnnouncementEmail: v + }); + }, } }); diff --git a/src/models/entities/user-profile.ts b/src/models/entities/user-profile.ts index 0e2c660325..4fab52868f 100644 --- a/src/models/entities/user-profile.ts +++ b/src/models/entities/user-profile.ts @@ -133,6 +133,11 @@ export class UserProfile { }) public injectFeaturedNote: boolean; + @Column('boolean', { + default: true, + }) + public receiveAnnouncementEmail: boolean; + @Column({ ...id(), nullable: true diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts index 7bf11b3167..88861224a4 100644 --- a/src/models/repositories/user.ts +++ b/src/models/repositories/user.ts @@ -236,6 +236,7 @@ export class UserRepository extends Repository { avatarId: user.avatarId, bannerId: user.bannerId, injectFeaturedNote: profile!.injectFeaturedNote, + receiveAnnouncementEmail: profile!.receiveAnnouncementEmail, alwaysMarkNsfw: profile!.alwaysMarkNsfw, carefulBot: profile!.carefulBot, autoAcceptFollowed: profile!.autoAcceptFollowed, diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 8ac427cd5b..6552f9b760 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -135,6 +135,10 @@ export const meta = { validator: $.optional.bool, }, + receiveAnnouncementEmail: { + validator: $.optional.bool, + }, + alwaysMarkNsfw: { validator: $.optional.bool, desc: { @@ -219,6 +223,7 @@ export default define(meta, async (ps, user, token) => { if (typeof ps.noCrawle === 'boolean') profileUpdates.noCrawle = ps.noCrawle; if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat; if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote; + if (typeof ps.receiveAnnouncementEmail === 'boolean') profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail; if (typeof ps.alwaysMarkNsfw === 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw; if (ps.avatarId) {