Skip to content

Commit

Permalink
enhance: 禁止ワードはリモートノートも対象に (misskey-dev#13280)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamaina authored and kanarikanaru committed Feb 12, 2024
1 parent d56f4fb commit f61fe24
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/test/e2e/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -678,7 +678,7 @@ describe('Note', () => {
text: 'hogetesthuge',
}, tom);

assert.strictEqual(note1.status, 200);
assert.strictEqual(note1.status, 400);
});
});

Expand Down
1 change: 1 addition & 0 deletions packages/backend/test/unit/activitypub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ describe('ActivityPub', () => {
perRemoteUserUserTimelineCacheMax: 100,
blockedHosts: [] as string[],
sensitiveWords: [] as string[],
prohibitedWords: [] as string[],
} as MiMeta;
let meta = metaInitial;

Expand Down

0 comments on commit f61fe24

Please sign in to comment.