summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteCreateService.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-12-24 15:23:56 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-12-24 15:23:56 +0900
commit6fce36374d8756f47f96c7a04cd388c994bd047f (patch)
tree5f3f57dbed32e56a109d8e5a7bc503f5871129a1 /packages/backend/src/core/NoteCreateService.ts
parentci: Get api.json from Misskeyでupload-artifact@v4で同名artifactでエラ... (diff)
downloadsharkey-6fce36374d8756f47f96c7a04cd388c994bd047f.tar.gz
sharkey-6fce36374d8756f47f96c7a04cd388c994bd047f.tar.bz2
sharkey-6fce36374d8756f47f96c7a04cd388c994bd047f.zip
enhance(backend): センシティブワードの設定がハッシュタグトレンドにも適用されるように
Diffstat (limited to 'packages/backend/src/core/NoteCreateService.ts')
-rw-r--r--packages/backend/src/core/NoteCreateService.ts27
1 files changed, 1 insertions, 26 deletions
diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts
index 2bdff872ad..35baa1447d 100644
--- a/packages/backend/src/core/NoteCreateService.ts
+++ b/packages/backend/src/core/NoteCreateService.ts
@@ -253,7 +253,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';
@@ -705,31 +705,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);