summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/UtilityService.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-03-02 16:36:49 +0000
committerAmelia Yukii <amelia.yukii@shourai.de>2024-03-02 16:36:49 +0000
commitaf548d05ca821725eabd5a96241d3228b92186f0 (patch)
tree6d23f6739482466abcc71965cd83f9bbfb2c3ae0 /packages/backend/src/core/UtilityService.ts
parentmerge: Fix Images in ReadMe (!445) (diff)
downloadsharkey-af548d05ca821725eabd5a96241d3228b92186f0.tar.gz
sharkey-af548d05ca821725eabd5a96241d3228b92186f0.tar.bz2
sharkey-af548d05ca821725eabd5a96241d3228b92186f0.zip
merge upstream for 2024.2.1
Diffstat (limited to 'packages/backend/src/core/UtilityService.ts')
-rw-r--r--packages/backend/src/core/UtilityService.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts
index 638a0c019e..652e8f7449 100644
--- a/packages/backend/src/core/UtilityService.ts
+++ b/packages/backend/src/core/UtilityService.ts
@@ -43,6 +43,20 @@ export class UtilityService {
}
@bindThis
+ 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;