MCPcopy Index your code
hub / github.com/simstudioai/sim / findConflictingWebhookPathOwner

Function findConflictingWebhookPathOwner

apps/sim/lib/webhooks/utils.server.ts:25–48  ·  view source on GitHub ↗
(params: {
  path: string
  workflowId: string
  tx?: DbOrTx
})

Source from the content-addressed store, hash-verified

23 * a same-workflow row can never mask a foreign collision.
24 */
25export async function findConflictingWebhookPathOwner(params: {
26 path: string
27 workflowId: string
28 tx?: DbOrTx
29}): Promise<string | null> {
30 const { path, workflowId, tx } = params
31 const dbCtx = tx ?? db
32
33 const existing = await dbCtx
34 .select({ workflowId: webhook.workflowId })
35 .from(webhook)
36 .innerJoin(workflow, eq(webhook.workflowId, workflow.id))
37 .where(
38 and(
39 eq(webhook.path, path),
40 eq(webhook.isActive, true),
41 isNull(webhook.archivedAt),
42 isNull(workflow.archivedAt)
43 )
44 )
45
46 const conflict = existing.find((row) => row.workflowId !== workflowId)
47 return conflict ? conflict.workflowId : null
48}
49
50/**
51 * Result of syncing webhooks for a credential set

Callers 2

route.tsFile · 0.90

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected