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

Function deleteSubscription

apps/sim/lib/webhooks/providers/airtable.ts:571–742  ·  view source on GitHub ↗
({
    webhook: webhookRecord,
    workflow,
    requestId,
    strict,
  }: DeleteSubscriptionContext)

Source from the content-addressed store, hash-verified

569 },
570
571 async deleteSubscription({
572 webhook: webhookRecord,
573 workflow,
574 requestId,
575 strict,
576 }: DeleteSubscriptionContext): Promise<void> {
577 try {
578 const config = getProviderConfig(webhookRecord)
579 const { baseId, externalId } = config as {
580 baseId?: string
581 externalId?: string
582 }
583
584 if (!baseId) {
585 logger.warn(`[${requestId}] Missing baseId for Airtable webhook deletion`, {
586 webhookId: webhookRecord.id,
587 })
588 if (strict) throw new Error('Missing Airtable baseId for webhook deletion')
589 return
590 }
591
592 const baseIdValidation = validateAirtableId(baseId, 'app', 'baseId')
593 if (!baseIdValidation.isValid) {
594 logger.warn(`[${requestId}] Invalid Airtable base ID format, skipping deletion`, {
595 webhookId: webhookRecord.id,
596 baseId: baseId.substring(0, 20),
597 })
598 if (strict) throw new Error('Invalid Airtable baseId for webhook deletion')
599 return
600 }
601
602 const credentialId = config.credentialId as string | undefined
603 if (!credentialId) {
604 logger.warn(
605 `[${requestId}] Missing credentialId for Airtable webhook deletion ${webhookRecord.id}`
606 )
607 if (strict) throw new Error('Missing Airtable credentialId for webhook deletion')
608 return
609 }
610
611 const credentialOwner = await getCredentialOwner(credentialId, requestId)
612 const accessToken = credentialOwner
613 ? await refreshAccessTokenIfNeeded(
614 credentialOwner.accountId,
615 credentialOwner.userId,
616 requestId
617 )
618 : null
619 if (!accessToken) {
620 const message = `[${requestId}] Could not retrieve Airtable access token. Cannot delete webhook in Airtable.`
621 logger.warn(message, { webhookId: webhookRecord.id })
622 if (strict) throw new Error(message)
623 return
624 }
625
626 let resolvedExternalId: string | undefined = externalId
627 let externalIdLookupFailed = false
628

Callers

nothing calls this directly

Calls 8

getProviderConfigFunction · 0.90
validateAirtableIdFunction · 0.90
getCredentialOwnerFunction · 0.90
getNotificationUrlFunction · 0.90
infoMethod · 0.80
errorMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected