fix(api): use inArray for /v1/me/workspace mesh-id filters
Some checks failed
CI / Lint (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Broker tests (Postgres) (push) Has been cancelled
CI / Docker build (linux/amd64) (push) Has been cancelled

drizzle's sql template literal interpolated meshIds as a tuple
(($1, $2, $3, ...)) instead of an array, breaking ANY() and
returning HTTP 500. inArray() emits the right binding shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-05-02 23:46:50 +01:00
parent 7de13cbb71
commit c7ce92f35b

View File

@@ -39,7 +39,7 @@ import {
messageQueue, messageQueue,
presence, presence,
} from "@turbostarter/db/schema/mesh"; } from "@turbostarter/db/schema/mesh";
import { and, asc, count, desc, eq, gt, isNull, lt, sql } from "drizzle-orm"; import { and, asc, count, desc, eq, gt, inArray, isNull, lt, sql } from "drizzle-orm";
import { validate } from "../../middleware"; import { validate } from "../../middleware";
import { import {
@@ -402,7 +402,7 @@ export const v1Router = new Hono<Env>()
return c.json({ return c.json({
userId: issuer.userId, userId: issuer.userId,
meshes: [], meshes: [],
totals: { meshes: 0, peers: 0, topics: 0, unreadMentions: 0 }, totals: { meshes: 0, peers: 0, online: 0, topics: 0, unreadMentions: 0 },
}); });
} }
@@ -417,10 +417,7 @@ export const v1Router = new Hono<Env>()
}) })
.from(meshMember) .from(meshMember)
.where( .where(
and( and(inArray(meshMember.meshId, meshIds), isNull(meshMember.revokedAt)),
sql`${meshMember.meshId} = ANY(${meshIds})`,
isNull(meshMember.revokedAt),
),
) )
.groupBy(meshMember.meshId); .groupBy(meshMember.meshId);
@@ -431,10 +428,7 @@ export const v1Router = new Hono<Env>()
}) })
.from(meshTopic) .from(meshTopic)
.where( .where(
and( and(inArray(meshTopic.meshId, meshIds), isNull(meshTopic.archivedAt)),
sql`${meshTopic.meshId} = ANY(${meshIds})`,
isNull(meshTopic.archivedAt),
),
) )
.groupBy(meshTopic.meshId); .groupBy(meshTopic.meshId);
@@ -446,10 +440,7 @@ export const v1Router = new Hono<Env>()
.from(presence) .from(presence)
.innerJoin(meshMember, eq(presence.memberId, meshMember.id)) .innerJoin(meshMember, eq(presence.memberId, meshMember.id))
.where( .where(
and( and(inArray(meshMember.meshId, meshIds), isNull(meshMember.revokedAt)),
sql`${meshMember.meshId} = ANY(${meshIds})`,
isNull(meshMember.revokedAt),
),
) )
.groupBy(meshMember.meshId); .groupBy(meshMember.meshId);
@@ -463,8 +454,8 @@ export const v1Router = new Hono<Env>()
.from(meshNotification) .from(meshNotification)
.where( .where(
and( and(
sql`${meshNotification.meshId} = ANY(${meshIds})`, inArray(meshNotification.meshId, meshIds),
sql`${meshNotification.recipientMemberId} = ANY(${myMemberIds})`, inArray(meshNotification.recipientMemberId, myMemberIds),
isNull(meshNotification.readAt), isNull(meshNotification.readAt),
), ),
) )