diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2021-02-19 21:42:47 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2021-02-19 21:42:47 +0900 |
| commit | d6c8b9b99470db45c201229b5c9235e7be3067de (patch) | |
| tree | 01e5fccad6d84cf1e7f41e0a5e3aae955f3695e0 /src/server/api/endpoints/notes/search.ts | |
| parent | Merge branch 'develop' (diff) | |
| parent | 12.70.0 (diff) | |
| download | misskey-d6c8b9b99470db45c201229b5c9235e7be3067de.tar.gz misskey-d6c8b9b99470db45c201229b5c9235e7be3067de.tar.bz2 misskey-d6c8b9b99470db45c201229b5c9235e7be3067de.zip | |
Merge branch 'develop'
Diffstat (limited to 'src/server/api/endpoints/notes/search.ts')
| -rw-r--r-- | src/server/api/endpoints/notes/search.ts | 15 |
1 files changed, 14 insertions, 1 deletions
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'); |