From 312588ba0ee19fa5a973a43ee26131f2be9caab7 Mon Sep 17 00:00:00 2001 From: frikky Date: Thu, 22 Apr 2021 17:44:54 +0200 Subject: [PATCH] Fixed bugs related to app execution --- backend/app_sdk/app_base.py | 8 +++++--- backend/go-app/main.go | 25 ++----------------------- docker-compose.yml | 2 +- frontend/src/views/AngularWorkflow.jsx | 2 +- 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/backend/app_sdk/app_base.py b/backend/app_sdk/app_base.py index 0fd4c9c2..6fa6f9a1 100644 --- a/backend/app_sdk/app_base.py +++ b/backend/app_sdk/app_base.py @@ -1212,7 +1212,10 @@ class AppBase: if len(value) == 0: return basejson, False - if isinstance(basejson[value], str): + if isinstance(basejson, list): + print("VALUE IN ISINSTANCE IS NOT TO BE USED (list): %s" % value) + return basejson, False + elif isinstance(basejson[value], str): print(f"LOADING STRING '%s' AS JSON" % basejson[value]) try: basejson = json.loads(basejson[value]) @@ -1754,7 +1757,7 @@ class AppBase: action["parameters"][counter]["value"] = json.dumps(newvalue) except json.decoder.JSONDecodeError as e: - print("Failed JSON replacement for OpenAPI keys (2) %s", val["key"]) + print("Failed JSON replacement for OpenAPI keys (2) {e}") #if "\n" in action["parameters"][counter]["value"]: # print("MODIFYING BODY!!") @@ -1852,7 +1855,6 @@ class AppBase: print("PRE new_replacement") - # FIXME: Only do this IF they want to loop new_replacement = [] for i in range(len(json_replacement)): if isinstance(json_replacement[i], dict) or isinstance(json_replacement[i], list): diff --git a/backend/go-app/main.go b/backend/go-app/main.go index de0800fa..793110a2 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -2457,12 +2457,6 @@ func handleWebhookCallback(resp http.ResponseWriter, request *http.Request) { log.Printf("This should trigger in the cloud. Duplicate action allowed onprem.") } - type ExecutionStruct struct { - Start string `json:"start"` - ExecutionSource string `json:"execution_source"` - ExecutionArgument string `json:"execution_argument"` - } - body, err := ioutil.ReadAll(request.Body) if err != nil { log.Printf("Body data error: %s", err) @@ -2476,26 +2470,11 @@ func handleWebhookCallback(resp http.ResponseWriter, request *http.Request) { // This is a specific fix for MSteams and may fix other things as well // Scared whether it may stop other things though, but that's a future problem // (famous last words) - parsedBody := string(body) - if strings.Contains(parsedBody, "choice") { - if strings.Count(parsedBody, `\\n`) > 2 { - parsedBody = strings.Replace(parsedBody, `\\n`, "", -1) - } - if strings.Count(parsedBody, `\u0022`) > 2 { - parsedBody = strings.Replace(parsedBody, `\u0022`, `"`, -1) - } - if strings.Count(parsedBody, `\\"`) > 2 { - parsedBody = strings.Replace(parsedBody, `\\"`, `"`, -1) - } - if strings.Contains(parsedBody, `"extra": "{`) { - parsedBody = strings.Replace(parsedBody, `"extra": "{`, `"extra": {`, 1) - parsedBody = strings.Replace(parsedBody, `}"}`, `}}`, 1) - } - } + parsedBody = shuffle.GetExecutiobody(body) //log.Printf("\n\nPARSEDBODY: %s", parsedBody) - newBody := ExecutionStruct{ + newBody := shuffle.ExecutionStruct{ Start: hook.Start, ExecutionSource: "webhook", ExecutionArgument: parsedBody, diff --git a/docker-compose.yml b/docker-compose.yml index dd791466..45d69899 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: frontend: - build: ./frontend + #build: ./frontend image: ghcr.io/frikky/shuffle-frontend:0.8.74 container_name: shuffle-frontend hostname: shuffle-frontend diff --git a/frontend/src/views/AngularWorkflow.jsx b/frontend/src/views/AngularWorkflow.jsx index dee43215..667176f6 100644 --- a/frontend/src/views/AngularWorkflow.jsx +++ b/frontend/src/views/AngularWorkflow.jsx @@ -1348,7 +1348,7 @@ const AngularWorkflow = (props) => { return } - if (originalLocation.x === 0 && originalLocation.y === 0) { + if (originalLocation.x === 0 && originalLocation.y === 0 && nodedata.position !== undefined) { console.log("Updating location!: ", nodedata) originalLocation.x = nodedata.position.x originalLocation.y = nodedata.position.y