feat: 通報通知を受け取るかオプションで選べるように、通報通知を受け取るメールアドレスを設定できるように

This commit is contained in:
Chocolate Pie 2023-08-04 13:08:24 +09:00
parent a7aba8a19a
commit 8018e4a285
9 changed files with 70 additions and 2 deletions

3
locales/index.d.ts vendored
View File

@ -1097,6 +1097,9 @@ export interface Locale {
"doYouAgree": string; "doYouAgree": string;
"beSureToReadThisAsItIsImportant": string; "beSureToReadThisAsItIsImportant": string;
"iHaveReadXCarefullyAndAgree": string; "iHaveReadXCarefullyAndAgree": string;
"doNotSendNotificationEmailsForAbuseReport": string;
"emailToReceiveAbuseReport": string;
"emailToReceiveAbuseReportCaption": string;
"_initialAccountSetting": { "_initialAccountSetting": {
"accountCreated": string; "accountCreated": string;
"letsStartAccountSetup": string; "letsStartAccountSetup": string;

View File

@ -1094,6 +1094,9 @@ expired: "期限切れ"
doYouAgree: "同意しますか?" doYouAgree: "同意しますか?"
beSureToReadThisAsItIsImportant: "重要ですので必ずお読みください。" beSureToReadThisAsItIsImportant: "重要ですので必ずお読みください。"
iHaveReadXCarefullyAndAgree: "「{x}」の内容をよく読み、同意します。" iHaveReadXCarefullyAndAgree: "「{x}」の内容をよく読み、同意します。"
doNotSendNotificationEmailsForAbuseReport: "通報の通知メールを発送しないようにする"
emailToReceiveAbuseReport: "通報通知を受け取るためのメールアドレス"
emailToReceiveAbuseReportCaption: "通報通知を受け取るためのメールアドレスを指定します。ここの入力欄を空にするとメールサーバーのメールアドレスが使用されます。"
_initialAccountSetting: _initialAccountSetting:
accountCreated: "アカウントの作成が完了しました!" accountCreated: "アカウントの作成が完了しました!"

View File

@ -0,0 +1,13 @@
export class NotificationEmailsForAbuseReport1691120548582 {
name = 'NotificationEmailsForAbuseReport1691120548582'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ADD "emailToReceiveAbuseReport" character varying(1024)`);
await queryRunner.query(`ALTER TABLE "meta" ADD "doNotSendNotificationEmailsForAbuseReport" boolean NOT NULL DEFAULT false`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "doNotSendNotificationEmailsForAbuseReport"`);
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "emailToReceiveAbuseReport"`);
}
}

View File

@ -41,6 +41,11 @@ export class Meta {
}) })
public maintainerEmail: string | null; public maintainerEmail: string | null;
@Column('varchar', {
length: 1024, nullable: true,
})
public emailToReceiveAbuseReport: string | null;
@Column('boolean', { @Column('boolean', {
default: false, default: false,
}) })
@ -432,6 +437,11 @@ export class Meta {
}) })
public enableIdenticonGeneration: boolean; public enableIdenticonGeneration: boolean;
@Column('boolean', {
default: false,
})
public doNotSendNotificationEmailsForAbuseReport: boolean;
@Column('jsonb', { @Column('jsonb', {
default: { }, default: { },
}) })

View File

@ -104,8 +104,8 @@ export class ReportAbuseProcessorService {
} }
const meta = await this.metaService.fetch(); const meta = await this.metaService.fetch();
if (meta.email) { if ((meta.emailToReceiveAbuseReport || meta.email) && !meta.doNotSendNotificationEmailsForAbuseReport) {
this.emailService.sendEmail(meta.email, 'New abuse report', this.emailService.sendEmail(meta.emailToReceiveAbuseReport ?? meta.email!, 'New abuse report',
sanitizeHtml(job.data.comment), sanitizeHtml(job.data.comment),
sanitizeHtml(job.data.comment)); sanitizeHtml(job.data.comment));
} }

View File

@ -278,6 +278,14 @@ export const meta = {
type: 'boolean', type: 'boolean',
optional: false, nullable: false, optional: false, nullable: false,
}, },
doNotSendNotificationEmailsForAbuseReport: {
type: 'boolean',
optional: false, nullable: false,
},
emailToReceiveAbuseReport: {
type: 'string',
optional: false, nullable: true,
},
policies: { policies: {
type: 'object', type: 'object',
optional: false, nullable: false, optional: false, nullable: false,
@ -383,6 +391,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
enableChartsForFederatedInstances: instance.enableChartsForFederatedInstances, enableChartsForFederatedInstances: instance.enableChartsForFederatedInstances,
enableServerMachineStats: instance.enableServerMachineStats, enableServerMachineStats: instance.enableServerMachineStats,
enableIdenticonGeneration: instance.enableIdenticonGeneration, enableIdenticonGeneration: instance.enableIdenticonGeneration,
doNotSendNotificationEmailsForAbuseReport: instance.doNotSendNotificationEmailsForAbuseReport,
emailToReceiveAbuseReport: instance.emailToReceiveAbuseReport,
policies: { ...DEFAULT_POLICIES, ...instance.policies }, policies: { ...DEFAULT_POLICIES, ...instance.policies },
}; };
}); });

View File

@ -104,6 +104,8 @@ export const paramDef = {
enableChartsForFederatedInstances: { type: 'boolean' }, enableChartsForFederatedInstances: { type: 'boolean' },
enableServerMachineStats: { type: 'boolean' }, enableServerMachineStats: { type: 'boolean' },
enableIdenticonGeneration: { type: 'boolean' }, enableIdenticonGeneration: { type: 'boolean' },
doNotSendNotificationEmailsForAbuseReport: { type: 'boolean' },
emailToReceiveAbuseReport: { type: 'string', nullable: true },
serverRules: { type: 'array', items: { type: 'string' } }, serverRules: { type: 'array', items: { type: 'string' } },
preservedUsernames: { type: 'array', items: { type: 'string' } }, preservedUsernames: { type: 'array', items: { type: 'string' } },
}, },
@ -419,6 +421,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
set.enableIdenticonGeneration = ps.enableIdenticonGeneration; set.enableIdenticonGeneration = ps.enableIdenticonGeneration;
} }
if (ps.doNotSendNotificationEmailsForAbuseReport !== undefined) {
set.doNotSendNotificationEmailsForAbuseReport = ps.doNotSendNotificationEmailsForAbuseReport;
}
if (ps.emailToReceiveAbuseReport !== undefined) {
set.emailToReceiveAbuseReport = ps.emailToReceiveAbuseReport;
}
if (ps.serverRules !== undefined) { if (ps.serverRules !== undefined) {
set.serverRules = ps.serverRules; set.serverRules = ps.serverRules;
} }

View File

@ -36,6 +36,12 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #caption>{{ i18n.ts.turnOffToImprovePerformance }}</template> <template #caption>{{ i18n.ts.turnOffToImprovePerformance }}</template>
</MkSwitch> </MkSwitch>
</div> </div>
<div class="_panel" style="padding: 16px;">
<MkSwitch v-model="doNotSendNotificationEmailsForAbuseReport">
<template #label>{{ i18n.ts.doNotSendNotificationEmailsForAbuseReport }}</template>
</MkSwitch>
</div>
</div> </div>
</FormSuspense> </FormSuspense>
</MkSpacer> </MkSpacer>
@ -56,6 +62,7 @@ let enableServerMachineStats: boolean = $ref(false);
let enableIdenticonGeneration: boolean = $ref(false); let enableIdenticonGeneration: boolean = $ref(false);
let enableChartsForRemoteUser: boolean = $ref(false); let enableChartsForRemoteUser: boolean = $ref(false);
let enableChartsForFederatedInstances: boolean = $ref(false); let enableChartsForFederatedInstances: boolean = $ref(false);
let doNotSendNotificationEmailsForAbuseReport: boolean = $ref(false);
async function init() { async function init() {
const meta = await os.api('admin/meta'); const meta = await os.api('admin/meta');
@ -63,6 +70,7 @@ async function init() {
enableIdenticonGeneration = meta.enableIdenticonGeneration; enableIdenticonGeneration = meta.enableIdenticonGeneration;
enableChartsForRemoteUser = meta.enableChartsForRemoteUser; enableChartsForRemoteUser = meta.enableChartsForRemoteUser;
enableChartsForFederatedInstances = meta.enableChartsForFederatedInstances; enableChartsForFederatedInstances = meta.enableChartsForFederatedInstances;
doNotSendNotificationEmailsForAbuseReport = meta.doNotSendNotificationEmailsForAbuseReport;
} }
function save() { function save() {
@ -71,6 +79,7 @@ function save() {
enableIdenticonGeneration, enableIdenticonGeneration,
enableChartsForRemoteUser, enableChartsForRemoteUser,
enableChartsForFederatedInstances, enableChartsForFederatedInstances,
doNotSendNotificationEmailsForAbuseReport,
}).then(() => { }).then(() => {
fetchInstance(); fetchInstance();
}); });

View File

@ -29,6 +29,12 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkInput> </MkInput>
</FormSplit> </FormSplit>
<MkInput v-model="emailToReceiveAbuseReport" type="email">
<template #prefix><i class="ti ti-mail"></i></template>
<template #label>{{ i18n.ts.emailToReceiveAbuseReport }}</template>
<template #caption>{{ i18n.ts.emailToReceiveAbuseReportCaption }}</template>
</MkInput>
<MkTextarea v-model="pinnedUsers"> <MkTextarea v-model="pinnedUsers">
<template #label>{{ i18n.ts.pinnedUsers }}</template> <template #label>{{ i18n.ts.pinnedUsers }}</template>
<template #caption>{{ i18n.ts.pinnedUsersDescription }}</template> <template #caption>{{ i18n.ts.pinnedUsersDescription }}</template>
@ -121,6 +127,7 @@ let name: string | null = $ref(null);
let description: string | null = $ref(null); let description: string | null = $ref(null);
let maintainerName: string | null = $ref(null); let maintainerName: string | null = $ref(null);
let maintainerEmail: string | null = $ref(null); let maintainerEmail: string | null = $ref(null);
let emailToReceiveAbuseReport: string | null = $ref(null);
let pinnedUsers: string = $ref(''); let pinnedUsers: string = $ref('');
let cacheRemoteFiles: boolean = $ref(false); let cacheRemoteFiles: boolean = $ref(false);
let cacheRemoteSensitiveFiles: boolean = $ref(false); let cacheRemoteSensitiveFiles: boolean = $ref(false);
@ -136,6 +143,7 @@ async function init(): Promise<void> {
description = meta.description; description = meta.description;
maintainerName = meta.maintainerName; maintainerName = meta.maintainerName;
maintainerEmail = meta.maintainerEmail; maintainerEmail = meta.maintainerEmail;
emailToReceiveAbuseReport = meta.emailToReceiveAbuseReport;
pinnedUsers = meta.pinnedUsers.join('\n'); pinnedUsers = meta.pinnedUsers.join('\n');
cacheRemoteFiles = meta.cacheRemoteFiles; cacheRemoteFiles = meta.cacheRemoteFiles;
cacheRemoteSensitiveFiles = meta.cacheRemoteSensitiveFiles; cacheRemoteSensitiveFiles = meta.cacheRemoteSensitiveFiles;
@ -152,6 +160,8 @@ function save(): void {
description, description,
maintainerName, maintainerName,
maintainerEmail, maintainerEmail,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
emailToReceiveAbuseReport: emailToReceiveAbuseReport || null,
pinnedUsers: pinnedUsers.split('\n'), pinnedUsers: pinnedUsers.split('\n'),
cacheRemoteFiles, cacheRemoteFiles,
cacheRemoteSensitiveFiles, cacheRemoteSensitiveFiles,