From 81d0709249a7666d0d23a05f1f86ad6c299d15be Mon Sep 17 00:00:00 2001 From: mattyatea Date: Fri, 16 Feb 2024 19:35:57 +0900 Subject: [PATCH] a --- .../backend/src/core/NoteCreateService.ts | 18 +++++++++++++ .../src/server/api/SignupApiService.ts | 26 +++++++++++++------ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 7ef2658e51..378c215b6c 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -265,6 +265,24 @@ export class NoteCreateService implements OnApplicationShutdown { } if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) { + const { DiscordWebhookUrl } = (await this.metaService.fetch()); + + if (DiscordWebhookUrl) { + const data_disc = { 'username': 'ノートブロックお知らせ', + 'content': + 'ユーザー名 :' + user.username + '\n' + + 'url : ' + user.host + '\n' + + 'contents : ' + data.text, + }; + + await fetch(DiscordWebhookUrl, { + 'method': 'post', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(data_disc), + }); + } throw new NoteCreateService.ContainsProhibitedWordsError(); } diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts index 01ca4ff612..38585b3888 100644 --- a/packages/backend/src/server/api/SignupApiService.ts +++ b/packages/backend/src/server/api/SignupApiService.ts @@ -75,14 +75,6 @@ export class SignupApiService { const instance = await this.metaService.fetch(true); - if (instance.enableProxyCheckio) { - if (instance.proxyCheckioApiKey == null) throw new FastifyReplyError(400, 'PROXY_CHECKIO_API_KEY_NOT_SET'); - const proxyCheck = new ProxyCheck({ api_key: instance.proxyCheckioApiKey }); - const result = await proxyCheck.check(request.headers['x-real-ip'] ?? request.ip, { - vpn: 1, - }); - if (result[request.headers['x-real-ip'] ?? request.ip].proxy === 'yes') throw new FastifyReplyError(400, 'PROXY_DETECTED'); - } // Verify *Captcha // ただしテスト時はこの機構は障害となるため無効にする if (process.env.NODE_ENV !== 'test') { @@ -117,6 +109,24 @@ export class SignupApiService { const invitationCode = body['invitationCode']; const emailAddress = body['emailAddress']; + const { DiscordWebhookUrl } = (await this.metaService.fetch()); + if (DiscordWebhookUrl) { + const data_disc = { 'username': 'ユーザー登録お知らせ', + 'content': + 'ユーザー名 :' + username + '\n' + + 'メールアドレス : ' + emailAddress + '\n' + + 'IPアドレス : ' + request.headers['x-real-ip'] ?? request.ip, + }; + + await fetch(DiscordWebhookUrl, { + 'method': 'post', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(data_disc), + }); + } + if (instance.emailRequiredForSignup) { if (emailAddress == null || typeof emailAddress !== 'string') { reply.code(400);