From 1fab19e03a98bfeb32d5eb9be8469c964104195e Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 8 Apr 2026 13:06:16 +0400 Subject: [PATCH] fix: bug --- apps/api/src/routes/monitors.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/api/src/routes/monitors.ts b/apps/api/src/routes/monitors.ts index 8f8aa44..84314ec 100644 --- a/apps/api/src/routes/monitors.ts +++ b/apps/api/src/routes/monitors.ts @@ -24,16 +24,16 @@ const MonitorBody = t.Object({ async function replaceMonitorChannels(monitorId: string, accountId: string, channelIds: string[]) { await sql`DELETE FROM monitor_notifications WHERE monitor_id = ${monitorId}`; if (channelIds.length === 0) return; - // Only attach channels that belong to the same account. + // Only attach channels that belong to the same account. Cast to uuid[] so the + // ANY() comparison against the uuid id column type-checks. const owned = await sql<{ id: string }[]>` SELECT id FROM notification_channels - WHERE account_id = ${accountId} AND id = ANY(${sql.array(channelIds)}) + WHERE account_id = ${accountId} + AND id = ANY(${sql.array(channelIds)}::uuid[]) `; if (owned.length === 0) return; - await sql` - INSERT INTO monitor_notifications (monitor_id, channel_id) - SELECT ${monitorId}, id FROM UNNEST(${sql.array(owned.map((o) => o.id))}::uuid[]) AS id - `; + const rows = owned.map((o) => ({ monitor_id: monitorId, channel_id: o.id })); + await sql`INSERT INTO monitor_notifications ${sql(rows, "monitor_id", "channel_id")}`; } export const monitors = new Elysia({ prefix: "/monitors" })