mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-27 10:20:27 +01:00
Add: メールドメインの自動ブラックリスト追加を追加
This commit is contained in:
parent
866cd43207
commit
a7270735b0
7 changed files with 52 additions and 0 deletions
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class AddAutoAddBannedEmailDomain1732535648378 {
|
||||
name = 'AddAutoAddBannedEmailDomain1732535648378'
|
||||
|
||||
async up(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "meta" ADD "enableAutoAddBannedEmailDomain" boolean NOT NULL DEFAULT false`);
|
||||
}
|
||||
|
||||
async down(queryRunner) {
|
||||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "enableAutoAddBannedEmailDomain"`);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import type { MiMeta, UserProfilesRepository } from '@/models/_.js';
|
|||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { HttpRequestService } from '@/core/HttpRequestService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
|
||||
@Injectable()
|
||||
export class EmailService {
|
||||
|
@ -34,6 +35,7 @@ export class EmailService {
|
|||
private loggerService: LoggerService,
|
||||
private utilityService: UtilityService,
|
||||
private httpRequestService: HttpRequestService,
|
||||
private metaService: MetaService,
|
||||
) {
|
||||
this.logger = this.loggerService.getLogger('email');
|
||||
}
|
||||
|
@ -227,6 +229,11 @@ export class EmailService {
|
|||
blacklist: 'blacklist',
|
||||
};
|
||||
|
||||
// 自動追加が有効な場合はブラックリストに追加する
|
||||
if (this.meta.enableAutoAddBannedEmailDomain) {
|
||||
await this.addBlockedHost(emailDomain);
|
||||
}
|
||||
|
||||
return {
|
||||
available: false,
|
||||
reason: validated.reason ? formatReason[validated.reason] ?? null : null,
|
||||
|
@ -372,4 +379,11 @@ export class EmailService {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
private async addBlockedHost(domain: string) {
|
||||
const set = {} as Partial<MiMeta>;
|
||||
set.bannedEmailDomains = this.meta.bannedEmailDomains;
|
||||
set.bannedEmailDomains.push(domain);
|
||||
await this.metaService.update(set);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -576,6 +576,11 @@ export class MiMeta {
|
|||
})
|
||||
public allowedEmailDomains: string[];
|
||||
|
||||
@Column('boolean', {
|
||||
default: false,
|
||||
})
|
||||
public enableAutoAddBannedEmailDomain: boolean;
|
||||
|
||||
@Column('varchar', {
|
||||
length: 1024, array: true, default: '{ "admin", "administrator", "root", "system", "maintainer", "host", "mod", "moderator", "owner", "superuser", "staff", "auth", "i", "me", "everyone", "all", "mention", "mentions", "example", "user", "users", "account", "accounts", "official", "help", "helps", "support", "supports", "info", "information", "informations", "announce", "announces", "announcement", "announcements", "notice", "notification", "notifications", "dev", "developer", "developers", "tech", "misskey" }',
|
||||
})
|
||||
|
|
|
@ -348,6 +348,10 @@ export const meta = {
|
|||
type: 'string',
|
||||
optional: false, nullable: true,
|
||||
},
|
||||
enableAutoAddBannedEmailDomain: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
enableChartsForRemoteUser: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
|
@ -645,6 +649,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
enableTruemailApi: instance.enableTruemailApi,
|
||||
truemailInstance: instance.truemailInstance,
|
||||
truemailAuthKey: instance.truemailAuthKey,
|
||||
enableAutoAddBannedEmailDomain: instance.enableAutoAddBannedEmailDomain,
|
||||
enableChartsForRemoteUser: instance.enableChartsForRemoteUser,
|
||||
enableChartsForFederatedInstances: instance.enableChartsForFederatedInstances,
|
||||
enableStatsForFederatedInstances: instance.enableStatsForFederatedInstances,
|
||||
|
|
|
@ -142,6 +142,7 @@ export const paramDef = {
|
|||
serverRules: { type: 'array', items: { type: 'string' } },
|
||||
bannedEmailDomains: { type: 'array', items: { type: 'string' } },
|
||||
allowedEmailDomains: { type: 'array', items: { type: 'string' } },
|
||||
enableAutoAddBannedEmailDomain: { type: 'boolean' },
|
||||
preservedUsernames: { type: 'array', items: { type: 'string' } },
|
||||
manifestJsonOverride: { type: 'string' },
|
||||
enableFanoutTimeline: { type: 'boolean' },
|
||||
|
@ -644,6 +645,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
set.allowedEmailDomains = ps.allowedEmailDomains;
|
||||
}
|
||||
|
||||
if (ps.enableAutoAddBannedEmailDomain !== undefined) {
|
||||
set.enableAutoAddBannedEmailDomain = ps.enableAutoAddBannedEmailDomain;
|
||||
}
|
||||
|
||||
if (ps.urlPreviewEnabled !== undefined) {
|
||||
set.urlPreviewEnabled = ps.urlPreviewEnabled;
|
||||
}
|
||||
|
|
|
@ -85,6 +85,9 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<template #prefix><i class="ti ti-key"></i></template>
|
||||
<template #label>TrueMail API Auth Key</template>
|
||||
</MkInput>
|
||||
<MkSwitch v-model="emailValidationForm.state.enableAutoAddBannedEmailDomain">
|
||||
<template #label>Enable Auto Add Banned Email Domain</template>
|
||||
</MkSwitch>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
|
@ -194,6 +197,7 @@ const emailValidationForm = useForm({
|
|||
enableTruemailApi: meta.enableTruemailApi,
|
||||
truemailInstance: meta.truemailInstance,
|
||||
truemailAuthKey: meta.truemailAuthKey,
|
||||
enableAutoAddBannedEmailDomain: meta.enableAutoAddBannedEmailDomain,
|
||||
}, async (state) => {
|
||||
await os.apiWithDialog('admin/update-meta', {
|
||||
enableActiveEmailValidation: state.enableActiveEmailValidation,
|
||||
|
@ -202,6 +206,7 @@ const emailValidationForm = useForm({
|
|||
enableTruemailApi: state.enableTruemailApi,
|
||||
truemailInstance: state.truemailInstance,
|
||||
truemailAuthKey: state.truemailAuthKey,
|
||||
enableAutoAddBannedEmailDomain: state.enableAutoAddBannedEmailDomain,
|
||||
});
|
||||
fetchInstance(true);
|
||||
});
|
||||
|
|
|
@ -5176,6 +5176,7 @@ export type operations = {
|
|||
enableTruemailApi: boolean;
|
||||
truemailInstance: string | null;
|
||||
truemailAuthKey: string | null;
|
||||
enableAutoAddBannedEmailDomain: boolean;
|
||||
enableChartsForRemoteUser: boolean;
|
||||
enableChartsForFederatedInstances: boolean;
|
||||
enableStatsForFederatedInstances: boolean;
|
||||
|
@ -9580,6 +9581,7 @@ export type operations = {
|
|||
serverRules?: string[];
|
||||
bannedEmailDomains?: string[];
|
||||
allowedEmailDomains?: string[];
|
||||
enableAutoAddBannedEmailDomain?: boolean;
|
||||
preservedUsernames?: string[];
|
||||
manifestJsonOverride?: string;
|
||||
enableFanoutTimeline?: boolean;
|
||||
|
|
Loading…
Reference in a new issue