Skip to content

Commit

Permalink
fix: Look up org webhook_url if not provided before sending event for…
Browse files Browse the repository at this point in the history
… webhook
  • Loading branch information
Tony committed Nov 23, 2024
1 parent 3d242aa commit 2bf8812
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/engine-backend/services/sync-service.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {clerkClient} from '@clerk/nextjs/server'
import type {Link as FetchLink} from '@opensdks/runtime'
import type {
AnyEntityPayload,
Expand Down Expand Up @@ -335,6 +336,15 @@ export function makeSyncService({
const endUserId = src.endUserId ?? dest.endUserId
const endUser = endUserId ? {id: endUserId} : null

// TODO: Maybe not the best place for this? Think where clerkClient should live
const org =
opts.org ??
(await clerkClient.organizations
.getOrganization({
organizationId: src.connectorConfig.orgId,
})
.then((r) => r.publicMetadata as {webhook_url?: string | null}))

const _source$ = sourceSync({
opts,
src,
Expand Down Expand Up @@ -410,7 +420,7 @@ export function makeSyncService({
source_id: src.id,
destination_id: dest.id,
},
user: opts.org,
user: org,
})
}

Expand Down

0 comments on commit 2bf8812

Please sign in to comment.