#342: Made workflow trigger run from real startnode
This commit is contained in:
+19
-1
@@ -2479,6 +2479,21 @@ func handleWebhookCallback(resp http.ResponseWriter, request *http.Request) {
|
|||||||
ExecutionArgument: parsedBody,
|
ExecutionArgument: parsedBody,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(hook.Workflows) == 1 {
|
||||||
|
workflow, err := shuffle.GetWorkflow(ctx, hook.Workflows[0])
|
||||||
|
if err == nil {
|
||||||
|
for _, branch := range workflow.Branches {
|
||||||
|
if branch.SourceID == hook.Id {
|
||||||
|
log.Printf("Found ID %s for hook", hook.Id)
|
||||||
|
if branch.DestinationID != hook.Start {
|
||||||
|
newBody.Start = branch.DestinationID
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
b, err := json.Marshal(newBody)
|
b, err := json.Marshal(newBody)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed newBody marshaling: %s", err)
|
log.Printf("Failed newBody marshaling: %s", err)
|
||||||
@@ -5359,6 +5374,9 @@ func runInit(ctx context.Context) {
|
|||||||
|
|
||||||
//log.Printf("Schedule: %#v", schedule)
|
//log.Printf("Schedule: %#v", schedule)
|
||||||
job := func() {
|
job := func() {
|
||||||
|
//log.Printf("[INFO] Running schedule %s with interval %d.", schedule.Id, schedule.Seconds)
|
||||||
|
//log.Printf("ARG: %s", schedule.WrappedArgument)
|
||||||
|
|
||||||
request := &http.Request{
|
request := &http.Request{
|
||||||
URL: url,
|
URL: url,
|
||||||
Method: "POST",
|
Method: "POST",
|
||||||
@@ -5367,7 +5385,7 @@ func runInit(ctx context.Context) {
|
|||||||
|
|
||||||
_, _, err := handleExecution(schedule.WorkflowId, shuffle.Workflow{}, request)
|
_, _, err := handleExecution(schedule.WorkflowId, shuffle.Workflow{}, request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to execute %s: %s", schedule.WorkflowId, err)
|
log.Printf("[WARNING] Failed to execute %s: %s", schedule.WorkflowId, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1657,7 +1657,7 @@ func handleExecution(id string, workflow shuffle.Workflow, request *http.Request
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
log.Printf("[ERROR] ACTION %s WAS NOT FOUND!", execution.Start)
|
log.Printf("[ERROR] Action %s was NOT found! Exiting execution.", execution.Start)
|
||||||
return shuffle.WorkflowExecution{}, fmt.Sprintf("Startnode %s was not found in actions", workflow.Start), errors.New(fmt.Sprintf("Startnode %s was not found in actions", workflow.Start))
|
return shuffle.WorkflowExecution{}, fmt.Sprintf("Startnode %s was not found in actions", workflow.Start), errors.New(fmt.Sprintf("Startnode %s was not found in actions", workflow.Start))
|
||||||
}
|
}
|
||||||
} else if len(execution.Start) > 0 {
|
} else if len(execution.Start) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user