MCPcopy
hub / github.com/simstudioai/sim / deleteSubscription

Function deleteSubscription

apps/sim/lib/webhooks/providers/fathom.ts:123–177  ·  view source on GitHub ↗
(ctx: DeleteSubscriptionContext)

Source from the content-addressed store, hash-verified

121 },
122
123 async deleteSubscription(ctx: DeleteSubscriptionContext): Promise<void> {
124 const { webhook, requestId } = ctx
125 try {
126 const config = getProviderConfig(webhook)
127 const apiKey = config.apiKey as string | undefined
128 const externalId = config.externalId as string | undefined
129
130 if (!apiKey) {
131 logger.warn(
132 `[${requestId}] Missing apiKey for Fathom webhook deletion ${webhook.id}, skipping cleanup`
133 )
134 if (ctx.strict) throw new Error('Missing Fathom apiKey for webhook deletion')
135 return
136 }
137
138 if (!externalId) {
139 logger.warn(
140 `[${requestId}] Missing externalId for Fathom webhook deletion ${webhook.id}, skipping cleanup`
141 )
142 if (ctx.strict) throw new Error('Missing Fathom externalId for webhook deletion')
143 return
144 }
145
146 const idValidation = validateAlphanumericId(externalId, 'Fathom webhook ID', 100)
147 if (!idValidation.isValid) {
148 logger.warn(
149 `[${requestId}] Invalid externalId format for Fathom webhook deletion ${webhook.id}, skipping cleanup`
150 )
151 if (ctx.strict) throw new Error('Invalid Fathom externalId for webhook deletion')
152 return
153 }
154
155 const fathomApiUrl = `https://api.fathom.ai/external/v1/webhooks/${externalId}`
156
157 const fathomResponse = await fetch(fathomApiUrl, {
158 method: 'DELETE',
159 headers: {
160 'X-Api-Key': apiKey,
161 'Content-Type': 'application/json',
162 },
163 })
164
165 if (!fathomResponse.ok && fathomResponse.status !== 404) {
166 logger.warn(
167 `[${requestId}] Failed to delete Fathom webhook (non-fatal): ${fathomResponse.status}`
168 )
169 if (ctx.strict) throw new Error(`Failed to delete Fathom webhook: ${fathomResponse.status}`)
170 } else {
171 logger.info(`[${requestId}] Successfully deleted Fathom webhook ${externalId}`)
172 }
173 } catch (error) {
174 logger.warn(`[${requestId}] Error deleting Fathom webhook (non-fatal)`, error)
175 if (ctx.strict) throw error
176 }
177 },
178}

Callers

nothing calls this directly

Calls 4

getProviderConfigFunction · 0.90
validateAlphanumericIdFunction · 0.90
infoMethod · 0.80
warnMethod · 0.65

Tested by

no test coverage detected