From b2a5076d14e84fc427e9ab59ae373b04ddfbf40c Mon Sep 17 00:00:00 2001 From: tamaina Date: Sat, 14 May 2022 15:24:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E6=A4=9C=E7=B4=A2=E3=81=A7=E3=80=81=E3=82=AF=E3=82=A8=E3=83=AA?= =?UTF-8?q?=E3=81=8Cusername=E3=81=AE=E6=9D=A1=E4=BB=B6=E3=82=92=E6=BA=80?= =?UTF-8?q?=E3=81=9F=E3=81=99=E5=A0=B4=E5=90=88=E3=81=AFusername=E3=82=82L?= =?UTF-8?q?IKE=E6=A4=9C=E7=B4=A2=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=20(#8644)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix #8643 * 部分一致にする --- .../backend/src/server/api/endpoints/users/search.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/endpoints/users/search.ts b/packages/backend/src/server/api/endpoints/users/search.ts index a72a58a84..f93d4f718 100644 --- a/packages/backend/src/server/api/endpoints/users/search.ts +++ b/packages/backend/src/server/api/endpoints/users/search.ts @@ -61,7 +61,14 @@ export default define(meta, paramDef, async (ps, me) => { .getMany(); } else { const nameQuery = Users.createQueryBuilder('user') - .where('user.name ILIKE :query', { query: '%' + ps.query + '%' }) + .where(new Brackets(qb => { + qb.where('user.name ILIKE :query', { query: '%' + ps.query + '%' }); + + // Also search username if it qualifies as username + if (Users.validateLocalUsername(ps.query)) { + qb.orWhere('user.usernameLower LIKE :username', { username: '%' + ps.query.toLowerCase() + '%' }); + } + })) .andWhere(new Brackets(qb => { qb .where('user.updatedAt IS NULL') .orWhere('user.updatedAt > :activeThreshold', { activeThreshold: activeThreshold });