chore: improve webhook (#25998)

This commit is contained in:
非法操作 2025-09-21 12:16:31 +08:00 committed by GitHub
parent 59f56d8c94
commit 4ca14bfdad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 27 deletions

View File

@ -599,6 +599,10 @@ class AppDslService:
if data_type == NodeType.TRIGGER_SCHEDULE.value:
# override the config with the default config
node_data["config"] = TriggerScheduleNode.get_default_config()["config"]
if data_type == NodeType.TRIGGER_WEBHOOK.value:
# clear the webhook_url
node_data["webhook_url"] = ""
node_data["webhook_debug_url"] = ""
export_data["workflow"] = workflow_dict
dependencies = cls._extract_dependencies_from_workflow(workflow)

View File

@ -669,6 +669,7 @@ class WebhookService:
created_by=app.created_by,
)
session.add(webhook_record)
session.flush()
cache = Cache(record_id=webhook_record.id, node_id=node_id, webhook_id=webhook_record.webhook_id)
redis_client.set(f"{cls.__WEBHOOK_NODE_CACHE_KEY__}:{node_id}", cache.model_dump_json(), ex=60 * 60)
session.commit()

View File

@ -63,8 +63,6 @@ import {
import { WorkflowHistoryEvent, useWorkflowHistory } from './use-workflow-history'
import useInspectVarsCrud from './use-inspect-vars-crud'
import { getNodeUsedVars } from '../nodes/_base/components/variable/utils'
import { deleteWebhookUrl } from '@/service/apps'
import { useStore as useAppStore } from '@/app/components/app/store'
// Entry node deletion restriction has been removed to allow empty workflows
@ -76,7 +74,7 @@ export const useNodesInteractions = () => {
const reactflow = useReactFlow()
const { store: workflowHistoryStore } = useWorkflowHistoryStore()
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
const appId = useAppStore.getState().appDetail?.id
const {
checkNestedParallelLimit,
getAfterNodesInSameBranch,
@ -592,17 +590,6 @@ export const useNodesInteractions = () => {
deleteNodeInspectorVars(nodeId)
if (currentNode.data.type === BlockEnum.TriggerWebhook) {
if (appId) {
try {
deleteWebhookUrl({ appId, nodeId })
}
catch (error) {
console.error('Failed to delete webhook URL:', error)
}
}
}
if (currentNode.data.type === BlockEnum.Iteration) {
const iterationChildren = nodes.filter(node => node.parentId === currentNode.id)

View File

@ -26,14 +26,6 @@ const nodeDefault: NodeDefault<WebhookTriggerNodeType> = {
return nodes.filter(type => type !== BlockEnum.Start)
},
checkValid(payload: WebhookTriggerNodeType, t: any) {
// Validate webhook configuration
if (!payload.webhook_url) {
return {
isValid: false,
errorMessage: t('workflow.nodes.triggerWebhook.validation.webhookUrlRequired'),
}
}
// Validate parameter types for params and body
const parametersWithTypes = [
...(payload.params || []),

View File

@ -159,11 +159,7 @@ export const updateTracingStatus: Fetcher<CommonResponse, { appId: string; body:
// Webhook Trigger
export const fetchWebhookUrl: Fetcher<WebhookTriggerResponse, { appId: string; nodeId: string }> = ({ appId, nodeId }) => {
return post<WebhookTriggerResponse>(`apps/${appId}/workflows/triggers/webhook`, { params: { node_id: nodeId } })
}
export const deleteWebhookUrl: Fetcher<CommonResponse, { appId: string; nodeId: string }> = ({ appId, nodeId }) => {
return del<CommonResponse>(`apps/${appId}/workflows/triggers/webhook`, { params: { node_id: nodeId } })
return get<WebhookTriggerResponse>(`apps/${appId}/workflows/triggers/webhook`, { params: { node_id: nodeId } })
}
export const fetchTracingConfig: Fetcher<TracingConfig & { has_not_configured: true }, { appId: string; provider: TracingProvider }> = ({ appId, provider }) => {