summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/UtilityService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/backend/src/core/UtilityService.ts')
-rw-r--r--packages/backend/src/core/UtilityService.ts22
1 files changed, 18 insertions, 4 deletions
diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts
index 5dec36c89e..652e8f7449 100644
--- a/packages/backend/src/core/UtilityService.ts
+++ b/packages/backend/src/core/UtilityService.ts
@@ -1,5 +1,5 @@
/*
- * SPDX-FileCopyrightText: syuilo and other misskey contributors
+ * SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
@@ -43,13 +43,27 @@ export class UtilityService {
}
@bindThis
- public isSensitiveWordIncluded(text: string, sensitiveWords: string[]): boolean {
- if (sensitiveWords.length === 0) return false;
+ public concatNoteContentsForKeyWordCheck(content: {
+ cw?: string | null;
+ text?: string | null;
+ pollChoices?: string[] | null;
+ others?: string[] | null;
+ }): string {
+ /**
+ * ノートの内容を結合してキーワードチェック用の文字列を生成する
+ * cwとtextは内容が繋がっているかもしれないので間に何も入れずにチェックする
+ */
+ return `${content.cw ?? ''}${content.text ?? ''}\n${(content.pollChoices ?? []).join('\n')}\n${(content.others ?? []).join('\n')}`;
+ }
+
+ @bindThis
+ public isKeyWordIncluded(text: string, keyWords: string[]): boolean {
+ if (keyWords.length === 0) return false;
if (text === '') return false;
const regexpregexp = /^\/(.+)\/(.*)$/;
- const matched = sensitiveWords.some(filter => {
+ const matched = keyWords.some(filter => {
// represents RegExp
const regexp = filter.match(regexpregexp);
// This should never happen due to input sanitisation.