diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-12-24 15:23:56 +0900 |
|---|---|---|
| committer | Marie <marie@kaifa.ch> | 2023-12-28 09:42:47 +0100 |
| commit | 42cc909c5b94bd804e1974e64a75c16ca111dfb1 (patch) | |
| tree | 5941a207c4834f34cf9ace15e883095b8b6e0c7e /packages/backend/src/core/NoteCreateService.ts | |
| parent | merge: another batch of small ui tweaks (#255) (diff) | |
| download | sharkey-42cc909c5b94bd804e1974e64a75c16ca111dfb1.tar.gz sharkey-42cc909c5b94bd804e1974e64a75c16ca111dfb1.tar.bz2 sharkey-42cc909c5b94bd804e1974e64a75c16ca111dfb1.zip | |
enhance(backend): センシティブワードの設定がハッシュタグトレンドにも適用されるように
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
| -rw-r--r-- | packages/backend/src/core/NoteCreateService.ts | 27 |
1 files changed, 1 insertions, 26 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 6406bc4c50..583fa97aff 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -422,7 +422,7 @@ export class NoteCreateService implements OnApplicationShutdown { if (data.visibility === 'public' && data.channel == null) { const sensitiveWords = meta.sensitiveWords; - if (this.isSensitive(data, sensitiveWords)) { + if (this.utilityService.isSensitiveWordIncluded(data.cw ?? data.text ?? '', sensitiveWords)) { data.visibility = 'home'; } else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) { data.visibility = 'home'; @@ -990,31 +990,6 @@ export class NoteCreateService implements OnApplicationShutdown { } @bindThis - private isSensitive(note: Option, sensitiveWord: string[]): boolean { - if (sensitiveWord.length > 0) { - const text = note.cw ?? note.text ?? ''; - if (text === '') return false; - const matched = sensitiveWord.some(filter => { - // represents RegExp - const regexp = filter.match(/^\/(.+)\/(.*)$/); - // This should never happen due to input sanitisation. - if (!regexp) { - const words = filter.split(' '); - return words.every(keyword => text.includes(keyword)); - } - try { - return new RE2(regexp[1], regexp[2]).test(text); - } catch (err) { - // This should never happen due to input sanitisation. - return false; - } - }); - if (matched) return true; - } - return false; - } - - @bindThis private isQuote(note: Option): note is Option & { renote: MiNote } { // sync with misc/is-quote.ts return !!note.renote && (!!note.text || !!note.cw || (!!note.files && !!note.files.length) || !!note.poll); |