diff options
| author | まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com> | 2023-07-15 09:59:19 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-15 09:59:19 +0900 |
| commit | 9e330c9e38175012e4ca8f81ce9d3f05b7db7510 (patch) | |
| tree | 456a5779ff76864745f16fea41f5f872e137b509 /packages/backend/src/core | |
| parent | enhance: 招待機能の改善 (#11195) (diff) | |
| download | sharkey-9e330c9e38175012e4ca8f81ce9d3f05b7db7510.tar.gz sharkey-9e330c9e38175012e4ca8f81ce9d3f05b7db7510.tar.bz2 sharkey-9e330c9e38175012e4ca8f81ce9d3f05b7db7510.zip | |
feat: MeilisearchにIndexするノートの範囲を設定できるように (#11282)
Diffstat (limited to 'packages/backend/src/core')
| -rw-r--r-- | packages/backend/src/core/SearchService.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/packages/backend/src/core/SearchService.ts b/packages/backend/src/core/SearchService.ts index 28b8ee8073..392799da75 100644 --- a/packages/backend/src/core/SearchService.ts +++ b/packages/backend/src/core/SearchService.ts @@ -52,6 +52,7 @@ function compileQuery(q: Q): string { @Injectable() export class SearchService { + private readonly meilisearchIndexScope: 'local' | 'global' | string[] = 'local'; private meilisearchNoteIndex: Index | null = null; constructor( @@ -92,6 +93,10 @@ export class SearchService { }, }); } + + if (config.meilisearch?.scope) { + this.meilisearchIndexScope = config.meilisearch.scope; + } } @bindThis @@ -100,7 +105,22 @@ export class SearchService { if (!['home', 'public'].includes(note.visibility)) return; if (this.meilisearch) { - this.meilisearchNoteIndex!.addDocuments([{ + switch (this.meilisearchIndexScope) { + case 'global': + break; + + case 'local': + if (note.userHost == null) break; + return; + + default: { + if (note.userHost == null) break; + if (this.meilisearchIndexScope.includes(note.userHost)) break; + return; + } + } + + await this.meilisearchNoteIndex?.addDocuments([{ id: note.id, createdAt: note.createdAt.getTime(), userId: note.userId, |