1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-12-12 05:38:55 +09:00

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;
"beSureToReadThisAsItIsImportant": string;
"iHaveReadXCarefullyAndAgree": string;
"doNotSendNotificationEmailsForAbuseReport": string;
"emailToReceiveAbuseReport": string;
"emailToReceiveAbuseReportCaption": string;
"_initialAccountSetting": {
"accountCreated": string;
"letsStartAccountSetup": string;

View File

@ -1094,6 +1094,9 @@ expired: "期限切れ"
doYouAgree: "同意しますか?"
beSureToReadThisAsItIsImportant: "重要ですので必ずお読みください。"
iHaveReadXCarefullyAndAgree: "「{x}」の内容をよく読み、同意します。"
doNotSendNotificationEmailsForAbuseReport: "通報の通知メールを発送しないようにする"
emailToReceiveAbuseReport: "通報通知を受け取るためのメールアドレス"
emailToReceiveAbuseReportCaption: "通報通知を受け取るためのメールアドレスを指定します。ここの入力欄を空にするとメールサーバーのメールアドレスが使用されます。"
_initialAccountSetting:
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;
@Column('varchar', {
length: 1024, nullable: true,
})
public emailToReceiveAbuseReport: string | null;
@Column('boolean', {
default: false,
})
@ -432,6 +437,11 @@ export class Meta {
})
public enableIdenticonGeneration: boolean;
@Column('boolean', {
default: false,
})
public doNotSendNotificationEmailsForAbuseReport: boolean;
@Column('jsonb', {
default: { },
})

View File

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

View File

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

View File

@ -104,6 +104,8 @@ export const paramDef = {
enableChartsForFederatedInstances: { type: 'boolean' },
enableServerMachineStats: { type: 'boolean' },
enableIdenticonGeneration: { type: 'boolean' },
doNotSendNotificationEmailsForAbuseReport: { type: 'boolean' },
emailToReceiveAbuseReport: { type: 'string', nullable: true },
serverRules: { 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;
}
if (ps.doNotSendNotificationEmailsForAbuseReport !== undefined) {
set.doNotSendNotificationEmailsForAbuseReport = ps.doNotSendNotificationEmailsForAbuseReport;
}
if (ps.emailToReceiveAbuseReport !== undefined) {
set.emailToReceiveAbuseReport = ps.emailToReceiveAbuseReport;
}
if (ps.serverRules !== undefined) {
set.serverRules = ps.serverRules;
}

View File

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

View File

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