Files
zooqueenandHanzo Dev 70be050994 sqlite: drop the two query arguments it rejects
Same failure as skipDuplicates, confirmed the same way against a database
built from this schema: Prisma does not ignore these on sqlite, it rejects
the call.

  mode: "insensitive" — broke document search and listing, dataroom search,
    and the two download-by-email lookups. Plain `contains` goes through LIKE,
    which sqlite already treats case-insensitively for ascii, so dropping the
    argument keeps the behaviour. `equals` does NOT: sqlite compares with `=`
    case-sensitively, so the two lookups that matched a visitor's address that
    way now narrow with `contains` and settle it with an exact comparison —
    verify.ts was already doing that comparison, by-email.ts was not.

    One of these was invisible to tsc: the documents where clause is assembled
    from spreads into a variable, so nothing checked it against Prisma's type
    and only the runtime rejected it.

  array_contains — every webhook delivery was throwing instead of fanning out.
    Three copies of the same query, now one `subscribers()` that matches the
    trigger against the list. `Webhook.triggers` is another postgres String[]
    that became Json, so it is narrowed like the rest.

99 errors -> 11, no file worse than it was.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-09 11:56:11 -07:00

19 lines
695 B
TypeScript

import prisma from "@/lib/prisma";
/**
* The team's webhooks that asked for this trigger.
*
* Postgres selected these in the query with `array_contains` over the triggers
* column. Sqlite has no json array operator and Prisma rejects the argument
* outright, so the subscription list is matched here instead. A team has a
* handful of webhooks, and this already runs off the request path.
*/
export async function subscribers(teamId: string, trigger: string) {
const webhooks = await prisma.webhook.findMany({
where: { teamId },
select: { pId: true, url: true, secret: true, triggers: true },
});
return webhooks.filter((webhook) => webhook.triggers.includes(trigger));
}