From eefbe097c0e810bbda4108b4235b32bf0456b06f Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 19 Feb 2021 21:40:09 +0900 Subject: Resolve #7222 --- src/server/api/endpoints/notes/search.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/server/api') diff --git a/src/server/api/endpoints/notes/search.ts b/src/server/api/endpoints/notes/search.ts index 2c75d2a55a..1aca056299 100644 --- a/src/server/api/endpoints/notes/search.ts +++ b/src/server/api/endpoints/notes/search.ts @@ -46,6 +46,11 @@ export const meta = { validator: $.optional.nullable.type(ID), default: null }, + + channelId: { + validator: $.optional.nullable.type(ID), + default: null + }, }, res: { @@ -64,7 +69,15 @@ export const meta = { export default define(meta, async (ps, me) => { if (es == null) { - const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId) + const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId); + + if (ps.userId) { + query.andWhere('note.userId = :userId', { userId: ps.userId }); + } else if (ps.channelId) { + query.andWhere('note.channelId = :channelId', { channelId: ps.channelId }); + } + + query .andWhere('note.text ILIKE :q', { q: `%${ps.query}%` }) .leftJoinAndSelect('note.user', 'user'); -- cgit v1.2.3-freya