server: don't return users twice in search
All checks were successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-sw Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
Johann150 2023-01-01 21:22:53 +01:00
parent 338e898f56
commit 0b7c9095bf
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -64,7 +64,7 @@ export default define(meta, paramDef, async (ps, me) => {
.getMany();
} else {
const nameQuery = Users.createQueryBuilder('user')
.where(new Brackets(qb => {
.where(new Brackets(qb => {
qb.where('user.name ILIKE :query', { query: '%' + ps.query + '%' });
// Also search username if it qualifies as username
@ -103,6 +103,8 @@ export default define(meta, paramDef, async (ps, me) => {
const query = Users.createQueryBuilder('user')
.where(`user.id IN (${ profQuery.getQuery() })`)
// don't show users twice
.andWhere('user.id NOT IN (:...ids)', { ids: users.map(user => user.id) })
.andWhere(new Brackets(qb => { qb
.where('user.updatedAt IS NULL')
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });