お知らせメールを受け取るかどうかの設定を追加

This commit is contained in:
syuilo 2021-02-06 22:47:15 +09:00
parent 4ecd036d0a
commit 547da89c7d
6 changed files with 37 additions and 1 deletions

View File

@ -700,6 +700,7 @@ capacity: "容量"
inUse: "使用中" inUse: "使用中"
editCode: "コードを編集" editCode: "コードを編集"
apply: "適用" apply: "適用"
receiveAnnouncementFromInstance: "インスタンスからのお知らせを受け取る"
_plugin: _plugin:
install: "プラグインのインストール" install: "プラグインのインストール"

View File

@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";
export class announcementEmail1612619156584 implements MigrationInterface {
name = 'announcementEmail1612619156584'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user_profile" ADD "receiveAnnouncementEmail" boolean NOT NULL DEFAULT true`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "receiveAnnouncementEmail"`);
}
}

View File

@ -8,6 +8,10 @@
{{ $i.email || $ts.notSet }} {{ $i.email || $ts.notSet }}
</FormLink> </FormLink>
</FormGroup> </FormGroup>
<FormSwitch :value="$i.receiveAnnouncementEmail" @update:value="onChangeReceiveAnnouncementEmail">
{{ $ts.receiveAnnouncementFromInstance }}
</FormSwitch>
</FormBase> </FormBase>
</template> </template>
@ -19,6 +23,7 @@ import FormButton from '@/components/form/button.vue';
import FormLink from '@/components/form/link.vue'; import FormLink from '@/components/form/link.vue';
import FormBase from '@/components/form/base.vue'; import FormBase from '@/components/form/base.vue';
import FormGroup from '@/components/form/group.vue'; import FormGroup from '@/components/form/group.vue';
import FormSwitch from '@/components/form/switch.vue';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
@ -26,6 +31,7 @@ export default defineComponent({
FormBase, FormBase,
FormLink, FormLink,
FormButton, FormButton,
FormSwitch,
FormGroup, FormGroup,
}, },
@ -46,7 +52,11 @@ export default defineComponent({
}, },
methods: { methods: {
onChangeReceiveAnnouncementEmail(v) {
os.api('i/update', {
receiveAnnouncementEmail: v
});
},
} }
}); });
</script> </script>

View File

@ -133,6 +133,11 @@ export class UserProfile {
}) })
public injectFeaturedNote: boolean; public injectFeaturedNote: boolean;
@Column('boolean', {
default: true,
})
public receiveAnnouncementEmail: boolean;
@Column({ @Column({
...id(), ...id(),
nullable: true nullable: true

View File

@ -236,6 +236,7 @@ export class UserRepository extends Repository<User> {
avatarId: user.avatarId, avatarId: user.avatarId,
bannerId: user.bannerId, bannerId: user.bannerId,
injectFeaturedNote: profile!.injectFeaturedNote, injectFeaturedNote: profile!.injectFeaturedNote,
receiveAnnouncementEmail: profile!.receiveAnnouncementEmail,
alwaysMarkNsfw: profile!.alwaysMarkNsfw, alwaysMarkNsfw: profile!.alwaysMarkNsfw,
carefulBot: profile!.carefulBot, carefulBot: profile!.carefulBot,
autoAcceptFollowed: profile!.autoAcceptFollowed, autoAcceptFollowed: profile!.autoAcceptFollowed,

View File

@ -135,6 +135,10 @@ export const meta = {
validator: $.optional.bool, validator: $.optional.bool,
}, },
receiveAnnouncementEmail: {
validator: $.optional.bool,
},
alwaysMarkNsfw: { alwaysMarkNsfw: {
validator: $.optional.bool, validator: $.optional.bool,
desc: { 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.noCrawle === 'boolean') profileUpdates.noCrawle = ps.noCrawle;
if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat; if (typeof ps.isCat === 'boolean') updates.isCat = ps.isCat;
if (typeof ps.injectFeaturedNote === 'boolean') profileUpdates.injectFeaturedNote = ps.injectFeaturedNote; 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 (typeof ps.alwaysMarkNsfw === 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
if (ps.avatarId) { if (ps.avatarId) {