forked from FoundKeyGang/FoundKey
server: don't return users twice in search
This commit is contained in:
parent
338e898f56
commit
0b7c9095bf
1 changed files with 3 additions and 1 deletions
|
@ -64,7 +64,7 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
.getMany();
|
.getMany();
|
||||||
} else {
|
} else {
|
||||||
const nameQuery = Users.createQueryBuilder('user')
|
const nameQuery = Users.createQueryBuilder('user')
|
||||||
.where(new Brackets(qb => {
|
.where(new Brackets(qb => {
|
||||||
qb.where('user.name ILIKE :query', { query: '%' + ps.query + '%' });
|
qb.where('user.name ILIKE :query', { query: '%' + ps.query + '%' });
|
||||||
|
|
||||||
// Also search username if it qualifies as username
|
// 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')
|
const query = Users.createQueryBuilder('user')
|
||||||
.where(`user.id IN (${ profQuery.getQuery() })`)
|
.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
|
.andWhere(new Brackets(qb => { qb
|
||||||
.where('user.updatedAt IS NULL')
|
.where('user.updatedAt IS NULL')
|
||||||
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
.orWhere('user.updatedAt > :activeThreshold', { activeThreshold });
|
||||||
|
|
Loading…
Reference in a new issue