Skip to content

Commit 102645e

Browse files
committed
address bugbot comments
1 parent 66e5aef commit 102645e

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

apps/sim/lib/webhooks/deploy.ts

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,12 @@ export async function saveTriggerWebhooksForDeploy({
354354

355355
if (previousVersionId) {
356356
const webhooksToCleanup = allWorkflowWebhooks.filter(
357-
(wh) => wh.deploymentVersionId === previousVersionId || wh.deploymentVersionId === null
357+
(wh) => wh.deploymentVersionId === previousVersionId
358358
)
359359

360360
if (webhooksToCleanup.length > 0) {
361361
logger.info(
362-
`[${requestId}] Cleaning up ${webhooksToCleanup.length} external subscription(s) from previous version and drafts`
362+
`[${requestId}] Cleaning up ${webhooksToCleanup.length} external subscription(s) from previous version`
363363
)
364364
for (const wh of webhooksToCleanup) {
365365
try {
@@ -373,39 +373,13 @@ export async function saveTriggerWebhooksForDeploy({
373373

374374
const restorePreviousSubscriptions = async () => {
375375
if (!previousVersionId) return
376-
377-
const previousWebhooks = await db
378-
.select()
379-
.from(webhook)
380-
.where(eq(webhook.deploymentVersionId, previousVersionId))
381-
382-
if (previousWebhooks.length === 0) return
383-
384-
logger.info(
385-
`[${requestId}] Attempting to restore ${previousWebhooks.length} external subscription(s) for previous version`
386-
)
387-
for (const wh of previousWebhooks) {
388-
try {
389-
await createExternalWebhookSubscription(
390-
request,
391-
{
392-
id: wh.id,
393-
path: wh.path,
394-
provider: wh.provider,
395-
providerConfig: (wh.providerConfig as Record<string, unknown>) || {},
396-
},
397-
workflow,
398-
userId,
399-
requestId
400-
)
401-
logger.info(`[${requestId}] Restored external subscription for webhook ${wh.id}`)
402-
} catch (restoreError) {
403-
logger.error(
404-
`[${requestId}] Failed to restore external subscription for webhook ${wh.id}`,
405-
restoreError
406-
)
407-
}
408-
}
376+
await restorePreviousVersionWebhooks({
377+
request,
378+
workflow,
379+
userId,
380+
previousVersionId,
381+
requestId,
382+
})
409383
}
410384

411385
const webhooksByBlockId = new Map<string, typeof existingWebhooks>()

0 commit comments

Comments
 (0)