Skip to content

Commit ca3c7d0

Browse files
committed
idempotency
1 parent 0c3121e commit ca3c7d0

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

apps/sim/lib/core/idempotency/service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ export class IdempotencyService {
422422
normalizedHeaders?.['x-teams-notification-id'] ||
423423
normalizedHeaders?.['svix-id'] ||
424424
normalizedHeaders?.['linear-delivery'] ||
425-
normalizedHeaders?.['greenhouse-event-id']
425+
normalizedHeaders?.['greenhouse-event-id'] ||
426+
normalizedHeaders?.['x-zm-request-id'] ||
427+
normalizedHeaders?.['idempotency-key']
426428

427429
if (webhookIdHeader) {
428430
return `${webhookId}:${webhookIdHeader}`

apps/sim/lib/webhooks/providers/ashby.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ function validateAshbySignature(secretToken: string, signature: string, body: st
3333
}
3434

3535
export const ashbyHandler: WebhookProviderHandler = {
36+
extractIdempotencyId(body: unknown): string | null {
37+
const obj = body as Record<string, unknown>
38+
const webhookActionId = obj.webhookActionId
39+
if (typeof webhookActionId === 'string' && webhookActionId) {
40+
return `ashby:${webhookActionId}`
41+
}
42+
return null
43+
},
44+
3645
async formatInput({ body }: FormatInputContext): Promise<FormatInputResult> {
3746
const b = body as Record<string, unknown>
3847
return {

apps/sim/lib/webhooks/providers/gong.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ export async function verifyGongJwtAuth(ctx: AuthContext): Promise<NextResponse
123123
export const gongHandler: WebhookProviderHandler = {
124124
verifyAuth: verifyGongJwtAuth,
125125

126+
extractIdempotencyId(body: unknown): string | null {
127+
const obj = body as Record<string, unknown>
128+
const callData = obj.callData as Record<string, unknown> | undefined
129+
const metaData = callData?.metaData as Record<string, unknown> | undefined
130+
const id = metaData?.id
131+
if (typeof id === 'string' && id) {
132+
return `gong:${id}`
133+
}
134+
if (typeof id === 'number') {
135+
return `gong:${id}`
136+
}
137+
return null
138+
},
139+
126140
async formatInput({ body }: FormatInputContext): Promise<FormatInputResult> {
127141
const b = body as Record<string, unknown>
128142
const callData = b.callData as Record<string, unknown> | undefined

apps/sim/lib/webhooks/providers/telegram.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ export const telegramHandler: WebhookProviderHandler = {
2323
return null
2424
},
2525

26+
extractIdempotencyId(body: unknown): string | null {
27+
const obj = body as Record<string, unknown>
28+
const updateId = obj.update_id
29+
if (typeof updateId === 'number') {
30+
return `telegram:${updateId}`
31+
}
32+
return null
33+
},
34+
2635
async formatInput({ body }: FormatInputContext): Promise<FormatInputResult> {
2736
const b = body as Record<string, unknown>
2837
const rawMessage = (b?.message ||

apps/sim/lib/webhooks/providers/zoom.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -128,36 +128,6 @@ export const zoomHandler: WebhookProviderHandler = {
128128
return null
129129
},
130130

131-
extractIdempotencyId(body: unknown): string | null {
132-
const obj = body as Record<string, unknown>
133-
const event = obj.event
134-
const ts = obj.event_ts
135-
if (typeof event !== 'string' || ts === undefined || ts === null) {
136-
return null
137-
}
138-
const payload = obj.payload as Record<string, unknown> | undefined
139-
const inner = payload?.object as Record<string, unknown> | undefined
140-
const participant =
141-
inner?.participant &&
142-
typeof inner.participant === 'object' &&
143-
!Array.isArray(inner.participant)
144-
? (inner.participant as Record<string, unknown>)
145-
: null
146-
const participantStable =
147-
(typeof participant?.user_id === 'string' && participant.user_id) ||
148-
(typeof participant?.id === 'string' && participant.id) ||
149-
(typeof participant?.email === 'string' && participant.email) ||
150-
(typeof participant?.join_time === 'string' && participant.join_time) ||
151-
(typeof participant?.leave_time === 'string' && participant.leave_time) ||
152-
''
153-
const stable =
154-
participantStable ||
155-
(typeof inner?.uuid === 'string' && inner.uuid) ||
156-
(inner?.id !== undefined && inner.id !== null ? String(inner.id) : '') ||
157-
''
158-
return `zoom:${event}:${String(ts)}:${stable}`
159-
},
160-
161131
async matchEvent({ webhook: wh, workflow, body, requestId, providerConfig }: EventMatchContext) {
162132
const triggerId = providerConfig.triggerId as string | undefined
163133
const obj = body as Record<string, unknown>

0 commit comments

Comments
 (0)