Skip to content

Commit fddc1cf

Browse files
committed
Fix flushing
1 parent 886d44c commit fddc1cf

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/trigger-save/trigger-save.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export function TriggerSave({
442442
/>
443443
) : (
444444
<p className='text-muted-foreground text-xs'>
445-
Generate a temporary URL that executes this webhook against the live (un-deployed)
445+
Generate a temporary URL that executes this webhook against the live (undeployed)
446446
workflow state.
447447
</p>
448448
)}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/webhook/components/webhook-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ export function WebhookModal({
897897
) : (
898898
<p className='text-muted-foreground text-xs'>
899899
Generate a temporary URL that executes this webhook against the live
900-
(un-deployed) workflow state.
900+
(undeployed) workflow state.
901901
</p>
902902
)}
903903
{testUrlExpiresAt && (

apps/sim/lib/workflows/db-helpers.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import crypto from 'crypto'
22
import {
33
db,
4+
webhook,
45
workflow,
56
workflowBlocks,
67
workflowDeploymentVersion,
@@ -249,6 +250,11 @@ export async function saveWorkflowToNormalizedTables(
249250
try {
250251
// Start a transaction
251252
await db.transaction(async (tx) => {
253+
const existingWebhooks = await tx
254+
.select()
255+
.from(webhook)
256+
.where(eq(webhook.workflowId, workflowId))
257+
252258
// Clear existing data for this workflow
253259
await Promise.all([
254260
tx.delete(workflowBlocks).where(eq(workflowBlocks.workflowId, workflowId)),
@@ -320,6 +326,26 @@ export async function saveWorkflowToNormalizedTables(
320326
if (subflowInserts.length > 0) {
321327
await tx.insert(workflowSubflows).values(subflowInserts)
322328
}
329+
330+
if (existingWebhooks.length > 0) {
331+
const webhookInserts = existingWebhooks
332+
.filter((wh) => !!state.blocks?.[wh.blockId ?? ''])
333+
.map((wh) => ({
334+
id: wh.id,
335+
workflowId: wh.workflowId,
336+
blockId: wh.blockId,
337+
path: wh.path,
338+
provider: wh.provider,
339+
providerConfig: wh.providerConfig,
340+
isActive: wh.isActive,
341+
createdAt: wh.createdAt,
342+
updatedAt: new Date(),
343+
}))
344+
345+
if (webhookInserts.length > 0) {
346+
await tx.insert(webhook).values(webhookInserts)
347+
}
348+
}
323349
})
324350

325351
return { success: true }

0 commit comments

Comments
 (0)