summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2021-02-19 21:40:09 +0900
committersyuilo <syuilotan@yahoo.co.jp>2021-02-19 21:40:09 +0900
commiteefbe097c0e810bbda4108b4235b32bf0456b06f (patch)
tree001c5fc97cbd38caa4c9eaee17c2c043b491a792 /src/server/api/endpoints
parentunisonReload (diff)
downloadsharkey-eefbe097c0e810bbda4108b4235b32bf0456b06f.tar.gz
sharkey-eefbe097c0e810bbda4108b4235b32bf0456b06f.tar.bz2
sharkey-eefbe097c0e810bbda4108b4235b32bf0456b06f.zip
Resolve #7222
Diffstat (limited to 'src/server/api/endpoints')
-rw-r--r--src/server/api/endpoints/notes/search.ts15
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');