From 407eb5e20571d7c7fd798555ba9df5a4de2b2e33 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Wed, 17 Jul 2024 01:26:24 +0200 Subject: [PATCH] feat(api): :sparkles: Make account searches case-insensitive --- server/api/api/v1/accounts/search/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/api/api/v1/accounts/search/index.ts b/server/api/api/v1/accounts/search/index.ts index 4c3350fd..e2198e01 100644 --- a/server/api/api/v1/accounts/search/index.ts +++ b/server/api/api/v1/accounts/search/index.ts @@ -4,7 +4,7 @@ import type { Hono } from "@hono/hono"; import { zValidator } from "@hono/zod-validator"; import { SignatureConstructor } from "@lysand-org/federation"; import { FederationRequester } from "@lysand-org/federation/requester"; -import { eq, like, not, or, sql } from "drizzle-orm"; +import { eq, ilike, not, or, sql } from "drizzle-orm"; import { anyOf, charIn, @@ -114,8 +114,8 @@ export default (app: Hono) => accounts.push( ...(await User.manyFromSql( or( - like(Users.displayName, `%${q}%`), - like(Users.username, `%${q}%`), + ilike(Users.displayName, `%${q}%`), + ilike(Users.username, `%${q}%`), following && self ? sql`EXISTS (SELECT 1 FROM "Relationships" WHERE "Relationships"."subjectId" = ${Users.id} AND "Relationships"."ownerId" = ${self.id} AND "Relationships"."following" = true)` : undefined,