@@ -21,23 +21,34 @@ def __init__(self, redis, logger, console_logger=None):
21
21
super ().__init__ (redis , logger , console_logger )
22
22
23
23
# Should run user input
24
- def run_userinput (self , user_apikey , sms = "" , email = "" , subflow = "" , information = "" , startnode = "" , backend_url = "" ):
24
+ def run_userinput (self , user_apikey , sms = "" , email = "" , subflow = "" , information = "" , startnode = "" , backend_url = "" , source_node = "" ):
25
25
#url = "%s/api/v1/workflows/%s/execute" % (self.url, workflow)
26
26
27
27
headers = {
28
28
"Authorization" : "Bearer %s" % user_apikey ,
29
- "User-Agent" : "Shuffle Userinput 1.0 .0"
29
+ "User-Agent" : "Shuffle Userinput 1.1 .0"
30
30
}
31
31
32
32
result = {
33
33
"success" : True ,
34
34
"source" : "userinput" ,
35
- "reason" : "Userinput data sent and workflow paused. Waiting for user input before continuing workflow."
35
+ "reason" : "Userinput data sent and workflow paused. Waiting for user input before continuing workflow." ,
36
+ "information" : information ,
37
+ "click_info" : {
38
+ "clicked" : False ,
39
+ "time" : "" ,
40
+ "ip" : "" ,
41
+ "user" : "" ,
42
+ "note" : "" ,
43
+ }
36
44
}
37
45
38
46
url = self .url
47
+ if len (self .base_url ) > 0 :
48
+ url = self .base_url
49
+
39
50
if len (str (backend_url )) > 0 :
40
- url = "%s" % ( backend_url )
51
+ url = backend_url
41
52
42
53
print ("Found backend url: %s" % url )
43
54
#if len(information):
@@ -50,20 +61,31 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
50
61
#print("Subflows to run from userinput: ", subflows)
51
62
52
63
subflows = subflow .split ("," )
64
+ frontend_url = url
65
+ if ":5001" in frontend_url :
66
+ print ("Should change port to 3001." )
67
+ if "appspot.com" in frontend_url :
68
+ frontend_url = "https://shuffler.io"
69
+
53
70
for item in subflows :
54
71
# In case of URL being passed, and not just ID
55
72
if "/" in item :
56
73
item = item .split ("/" )[- 1 ]
57
74
75
+ # Subflow should be the subflow to run
76
+ # Workflow in the URL should be the source workflow
58
77
argument = json .dumps ({
59
78
"information" : information ,
60
79
"parent_workflow" : self .full_execution ["workflow" ]["id" ],
61
- "continue_url" : "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (url , item , user_apikey , self .full_execution ["execution_id" ]),
62
- "abort_url" : "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (url , item , user_apikey , self .full_execution ["execution_id" ]),
80
+ "frontend_continue" : "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=true" % (frontend_url , self .full_execution ["workflow" ]["id" ], self .full_execution ["authorization" ], self .full_execution ["execution_id" ]),
81
+ "frontend_abort" : "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=false" % (frontend_url , self .full_execution ["workflow" ]["id" ], self .full_execution ["authorization" ], self .full_execution ["execution_id" ]),
82
+ "api_continue" : "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (frontend_url , self .full_execution ["workflow" ]["id" ], self .full_execution ["authorization" ], self .full_execution ["execution_id" ]),
83
+ "api_abort" : "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=false" % (frontend_url , self .full_execution ["workflow" ]["id" ], self .full_execution ["authorization" ], self .full_execution ["execution_id" ]),
63
84
})
64
85
65
- ret = self .run_subflow (user_apikey , item , argument , source_workflow = self .full_execution ["workflow" ]["id" ], source_execution = self .full_execution ["execution_id" ], source_auth = self .full_execution ["authorization" ], startnode = startnode , backend_url = backend_url )
86
+ ret = self .run_subflow (user_apikey , item , argument , source_workflow = self .full_execution ["workflow" ]["id" ], source_execution = self .full_execution ["execution_id" ], source_auth = self .full_execution ["authorization" ], startnode = startnode , backend_url = backend_url , source_node = source_node )
66
87
result ["subflow" ] = ret
88
+ result ["subflow_url" ] = "%s/workflows/%s" % (frontend_url , item )
67
89
68
90
if len (email ):
69
91
jsondata = {
@@ -74,6 +96,7 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
74
96
"start" : startnode ,
75
97
"workflow_id" : self .full_execution ["workflow" ]["id" ],
76
98
"reference_execution" : self .full_execution ["execution_id" ],
99
+ "authorization" : self .full_execution ["authorization" ],
77
100
}
78
101
79
102
for item in email .split ("," ):
@@ -98,6 +121,7 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
98
121
"start" : startnode ,
99
122
"workflow_id" : self .full_execution ["workflow" ]["id" ],
100
123
"reference_execution" : self .full_execution ["execution_id" ],
124
+ "authorization" : self .full_execution ["authorization" ],
101
125
}
102
126
103
127
for item in sms .split ("," ):
0 commit comments