From f61fe243c22fe97071f55f5f8cee5d129a1f4d5b Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 13 Feb 2024 04:54:01 +0900 Subject: [PATCH] =?UTF-8?q?enhance:=20=E7=A6=81=E6=AD=A2=E3=83=AF=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=AF=E3=83=AA=E3=83=A2=E3=83=BC=E3=83=88=E3=83=8E?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=82=82=E5=AF=BE=E8=B1=A1=E3=81=AB=20(#1328?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve #13279 --- packages/backend/src/core/NoteCreateService.ts | 6 ++---- packages/backend/test/e2e/note.ts | 4 ++-- packages/backend/test/unit/activitypub.ts | 1 + 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 7922d2344ab0..d529969d1468 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -263,10 +263,8 @@ export class NoteCreateService implements OnApplicationShutdown { } } - if (!user.host) { - if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) { - throw new NoteCreateService.ContainsProhibitedWordsError(); - } + if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', meta.prohibitedWords)) { + throw new NoteCreateService.ContainsProhibitedWordsError(); } const inSilencedInstance = this.utilityService.isSilencedHost(meta.silencedHosts, user.host); diff --git a/packages/backend/test/e2e/note.ts b/packages/backend/test/e2e/note.ts index 1bc8cb591c81..34c9376b2bda 100644 --- a/packages/backend/test/e2e/note.ts +++ b/packages/backend/test/e2e/note.ts @@ -663,7 +663,7 @@ describe('Note', () => { assert.strictEqual(note2.body.error.code, 'CONTAINS_PROHIBITED_WORDS'); }); - test('禁止ワードを含んでいてもリモートノートはエラーにならない', async () => { + test('禁止ワードを含んでるリモートノートもエラーになる', async () => { const prohibited = await api('admin/update-meta', { prohibitedWords: [ 'test', @@ -678,7 +678,7 @@ describe('Note', () => { text: 'hogetesthuge', }, tom); - assert.strictEqual(note1.status, 200); + assert.strictEqual(note1.status, 400); }); }); diff --git a/packages/backend/test/unit/activitypub.ts b/packages/backend/test/unit/activitypub.ts index 63952e6434fb..c150165ee357 100644 --- a/packages/backend/test/unit/activitypub.ts +++ b/packages/backend/test/unit/activitypub.ts @@ -100,6 +100,7 @@ describe('ActivityPub', () => { perRemoteUserUserTimelineCacheMax: 100, blockedHosts: [] as string[], sensitiveWords: [] as string[], + prohibitedWords: [] as string[], } as MiMeta; let meta = metaInitial;