fix: Query not taken into account when filtering groups, closes #7291

This commit is contained in:
Tom Moor
2024-07-23 22:49:57 -04:00
parent 87aacae479
commit e033b20d6f
2 changed files with 12 additions and 2 deletions
+8 -1
View File
@@ -25,7 +25,7 @@ router.post(
pagination(),
validate(T.GroupsListSchema),
async (ctx: APIContext<T.GroupsListReq>) => {
const { direction, sort, userId, name } = ctx.input.body;
const { sort, direction, query, userId, name } = ctx.input.body;
const { user } = ctx.state.auth;
authorize(user, "listGroups", user.team);
@@ -40,6 +40,13 @@ router.post(
[Op.eq]: name,
},
};
} else if (query) {
where = {
...where,
name: {
[Op.iLike]: `%${query}%`,
},
};
}
const groups = await Group.filterByMember(userId).findAll({
+4 -1
View File
@@ -25,8 +25,11 @@ export const GroupsListSchema = z.object({
/** Only list groups where this user is a member */
userId: z.string().uuid().optional(),
/** Find group with matching name */
/** @deprecated Find group with matching name */
name: z.string().optional(),
/** Find group matching query */
query: z.string().optional(),
}),
});