feat: Add draft hash check in workflow (#4251)

This commit is contained in:
takatost
2024-05-10 14:48:29 +08:00
committed by GitHub
parent a1ab87107b
commit 8f3042e5b3
7 changed files with 53 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ from models.workflow import (
WorkflowNodeExecutionTriggeredFrom,
WorkflowType,
)
from services.errors.app import WorkflowHashNotEqualError
from services.workflow.workflow_converter import WorkflowConverter
@@ -63,13 +64,20 @@ class WorkflowService:
def sync_draft_workflow(self, app_model: App,
graph: dict,
features: dict,
unique_hash: Optional[str],
account: Account) -> Workflow:
"""
Sync draft workflow
@throws WorkflowHashNotEqualError
"""
# fetch draft workflow by app_model
workflow = self.get_draft_workflow(app_model=app_model)
if workflow:
# validate unique hash
if workflow.unique_hash != unique_hash:
raise WorkflowHashNotEqualError()
# validate features structure
self.validate_features_structure(
app_model=app_model,