mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-25 06:48:12 -05:00
Compare commits
1 Commits
fix/ci-com
...
fix/slack-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6bc5eaeac |
@@ -1,15 +1,33 @@
|
|||||||
|
import { createLogger } from '@/lib/logs/console/logger'
|
||||||
|
|
||||||
|
const logger = createLogger('ProviderUtils')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider-specific unique identifier extractors for webhook idempotency
|
* Provider-specific unique identifier extractors for webhook idempotency
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the unique event_id from Slack Events API payloads.
|
||||||
|
* The event_id is globally unique and is the correct idempotency key for Slack.
|
||||||
|
* Slack retries send the same event_id, so using this prevents duplicate processing.
|
||||||
|
*/
|
||||||
function extractSlackIdentifier(body: any): string | null {
|
function extractSlackIdentifier(body: any): string | null {
|
||||||
|
// Use event_id from Slack Events API - this is the only correct identifier
|
||||||
|
// Slack includes event_id in all event_callback type payloads
|
||||||
if (body.event_id) {
|
if (body.event_id) {
|
||||||
|
logger.debug('Extracted Slack event_id for idempotency', {
|
||||||
|
event_id: body.event_id,
|
||||||
|
event_type: body.event?.type,
|
||||||
|
})
|
||||||
return body.event_id
|
return body.event_id
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.event?.ts && body.team_id) {
|
// No event_id means this is not a standard event_callback payload
|
||||||
return `${body.team_id}:${body.event.ts}`
|
// Log warning as this will cause duplicate processing issues
|
||||||
}
|
logger.warn('No Slack event_id found for idempotency', {
|
||||||
|
bodyType: body.type,
|
||||||
|
bodyKeys: Object.keys(body || {}),
|
||||||
|
})
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user