enhance(backend): SearchService.searchNoteでhost指定対応
This commit is contained in:
parent
6ad9a9677a
commit
29a84230b0
2 changed files with 10 additions and 2 deletions
|
@ -117,6 +117,7 @@ export class SearchService {
|
||||||
public async searchNote(q: string, me: User | null, opts: {
|
public async searchNote(q: string, me: User | null, opts: {
|
||||||
userId?: Note['userId'] | null;
|
userId?: Note['userId'] | null;
|
||||||
channelId?: Note['channelId'] | null;
|
channelId?: Note['channelId'] | null;
|
||||||
|
host?: string | null;
|
||||||
}, pagination: {
|
}, pagination: {
|
||||||
untilId?: Note['id'];
|
untilId?: Note['id'];
|
||||||
sinceId?: Note['id'];
|
sinceId?: Note['id'];
|
||||||
|
@ -131,6 +132,13 @@ export class SearchService {
|
||||||
if (pagination.sinceId) filter.qs.push({ op: '>', k: 'createdAt', v: this.idService.parse(pagination.sinceId).date.getTime() });
|
if (pagination.sinceId) filter.qs.push({ op: '>', k: 'createdAt', v: this.idService.parse(pagination.sinceId).date.getTime() });
|
||||||
if (opts.userId) filter.qs.push({ op: '=', k: 'userId', v: opts.userId });
|
if (opts.userId) filter.qs.push({ op: '=', k: 'userId', v: opts.userId });
|
||||||
if (opts.channelId) filter.qs.push({ op: '=', k: 'channelId', v: opts.channelId });
|
if (opts.channelId) filter.qs.push({ op: '=', k: 'channelId', v: opts.channelId });
|
||||||
|
if (opts.host) {
|
||||||
|
if (opts.host === '.') {
|
||||||
|
// TODO: Meilisearchが2023/05/07現在値がNULLかどうかのクエリが書けない
|
||||||
|
} else {
|
||||||
|
filter.qs.push({ op: '=', k: 'userHost', v: opts.host });
|
||||||
|
}
|
||||||
|
}
|
||||||
const res = await this.meilisearchNoteIndex!.search(q, {
|
const res = await this.meilisearchNoteIndex!.search(q, {
|
||||||
sort: ['createdAt:desc'],
|
sort: ['createdAt:desc'],
|
||||||
matchingStrategy: 'all',
|
matchingStrategy: 'all',
|
||||||
|
|
|
@ -42,8 +42,7 @@ export const paramDef = {
|
||||||
offset: { type: 'integer', default: 0 },
|
offset: { type: 'integer', default: 0 },
|
||||||
host: {
|
host: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
nullable: true,
|
description: 'The local host is represented with `.`.',
|
||||||
description: 'The local host is represented with `null`.',
|
|
||||||
},
|
},
|
||||||
userId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
userId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||||
channelId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
channelId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||||
|
@ -73,6 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
const notes = await this.searchService.searchNote(ps.query, me, {
|
const notes = await this.searchService.searchNote(ps.query, me, {
|
||||||
userId: ps.userId,
|
userId: ps.userId,
|
||||||
channelId: ps.channelId,
|
channelId: ps.channelId,
|
||||||
|
host: ps.host,
|
||||||
}, {
|
}, {
|
||||||
untilId: ps.untilId,
|
untilId: ps.untilId,
|
||||||
sinceId: ps.sinceId,
|
sinceId: ps.sinceId,
|
||||||
|
|
Loading…
Reference in a new issue