diff --git a/core/execution/operation/operation.py b/core/execution/operation/operation.py index e158581..23fe6bf 100644 --- a/core/execution/operation/operation.py +++ b/core/execution/operation/operation.py @@ -16,6 +16,9 @@ def buildOperation(definition, outputs): dependency in outputs["stopsignals"] for dependency in action.depends ) + + #print(f"STOP SIGNAL DEBUGGING during {action.name}") + #print(outputs["stopsignals"]) #stop = True #break diff --git a/core/execution/recursive.py b/core/execution/recursive.py index 4e5c9e4..cdeb1d0 100644 --- a/core/execution/recursive.py +++ b/core/execution/recursive.py @@ -1,3 +1,4 @@ +from core.execution import action from core.execution.action.action import buildAction from core.runtime.runtimecontract import buildPreRuntimeAttr, buildRuntimeAttr from core.apirequest import executeRequest @@ -33,15 +34,21 @@ def buildRecursive(definition, outputs): dependency in outputs["stopsignals"] for dependency in job.depends ) + + #print(f"STOP SIGNAL DEBUGGING during {job.name}") + #print(outputs["stopsignals"]) #stop = True #break if stop: + #print("STOP SIGNAL DETECTED") + #print(f"Stopping {job.name} due to stop signal") continue #print(f"RECURSIVE DEBUG DURING {job.name}") #print(item) #outputs, response = buildAction(job, outputs) + outputs, response = executeContract(job, outputs) responses.append(response) diff --git a/plugins/rmass/actions/getrmassuseravatar.py b/plugins/rmass/actions/getrmassuseravatar.py index e2d4cff..1b8ef40 100644 --- a/plugins/rmass/actions/getrmassuseravatar.py +++ b/plugins/rmass/actions/getrmassuseravatar.py @@ -4,7 +4,9 @@ name = "Get User Avatar" kind = "action" -alias = "getavatar" +alias = "getrmassuseravatar" + +depends = [] allowaction = bool(os.environ.get("UPDATE_AVATARS", True)) diff --git a/plugins/rmass/actions/pullmessagelist.py b/plugins/rmass/actions/pullmessagelist.py index 78a9ae0..11a1780 100644 --- a/plugins/rmass/actions/pullmessagelist.py +++ b/plugins/rmass/actions/pullmessagelist.py @@ -4,7 +4,7 @@ name = "Get message list" kind = "action" -alias = "pullmessages" +alias = "pullmessagelist" showstatus = True diff --git a/plugins/rmass/actions/rmassattachmentpush.py b/plugins/rmass/actions/rmassattachmentpush.py index 126d3b4..95aabad 100644 --- a/plugins/rmass/actions/rmassattachmentpush.py +++ b/plugins/rmass/actions/rmassattachmentpush.py @@ -48,17 +48,17 @@ resolve = { } keys = [ - #{ - # "keytitle": "message", - # "keyvalue": { - # "resolved": "message_body", - # }, - #}, { "keytitle": "message", - "keyvalue": "Here's a photo!", + "keyvalue": { + "resolved": "message_body", + }, }, #{ + # "keytitle": "message", + # "keyvalue": "Here's a photo!", + #}, + #{ # "keytitle": "profileId", # "keyvalue": { # "resolved": "rmass_user", diff --git a/plugins/rmass/actions/rmassattachmenttosynapse.py b/plugins/rmass/actions/rmassattachmenttosynapse.py index 48586c4..acc9441 100644 --- a/plugins/rmass/actions/rmassattachmenttosynapse.py +++ b/plugins/rmass/actions/rmassattachmenttosynapse.py @@ -2,7 +2,11 @@ name = "Upload Attachments to Synapse" kind = "action" -alias = "uploadattachment" +alias = "rmassuploadattachmenttosynapse" + +depends = [ + "getrmassattachments", +] showstatus = True diff --git a/plugins/rmass/actions/rmassavatartosynapse.py b/plugins/rmass/actions/rmassavatartosynapse.py index f8f8746..2a4a332 100644 --- a/plugins/rmass/actions/rmassavatartosynapse.py +++ b/plugins/rmass/actions/rmassavatartosynapse.py @@ -4,7 +4,11 @@ name = "Upload Avatar to Synapse" kind = "action" -alias = "uploadavatar" +alias = "rmassavatartosynapse" + +depends = [ + "getrmassuseravatar", +] allowaction = os.environ.get("UPDATE_AVATARS", True) diff --git a/plugins/rmass/actions/savermassmessageid.py b/plugins/rmass/actions/savermassmessageid.py new file mode 100644 index 0000000..1bca40e --- /dev/null +++ b/plugins/rmass/actions/savermassmessageid.py @@ -0,0 +1,94 @@ +name = "Save RMASS Message ID" + +kind = "action" + +alias = "savermassmessageid" + +depends = [ + "synapsegetroomalias", + "rmassmessagepush", + "rmassattachmentpush", +] + +showstatus = True + +isrequest = True + +method = "GET" + +#Used to resolve path for recursive handling. Path location must match the location of the recursiveset data from pullmessage operation +resolve = { + "get": { + "event_id": ["outmessageitem", "event_id"], + "path": ["lastmessage", 0, "content", "com.loxthelion.rmass_message_id"], + #"matrix_sender": ["outmessageitem", "sender"], + #"msg_type": ["outmessageitem", "type"], + #"echo_tag": ["outmessageitem", "content", "com.loxthelion.rmass_message_id"], + "rmass_sent_status": ["rmass_sent_status"], + }, +} + +#To add resolution suffix, second item must be a dictionary. References the "path" library under resolved +path = [ + "https://rentmasseur.com/api/v1/mailbox/", + {"resolved": "path"}, +] + +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + +outputs = { + "rmasslastmessages": "messages", +} + +extract = { + "get": { + "rmass_message_id": ["rmasslastmessages", 0, "id"], + }, +} + +#outputs["rmasslastmessages"][0]["id"] is where we get our messageid +select = { + "source": "rmasslastmessages", + "include": { + "key": "senderId", + "value": 238302, + }, + "exclude": { + "key": "currentFolder", + "value": 1, + } +} + +saverow = { + "table": "message_mapping", + "columns": [ + {"rmass_message_id": "INTEGER PRIMARY KEY"}, + {"matrix_event_id": "TEXT NOT NULL UNIQUE"}, + ], + + "rowitems": [ + {"outputs": "rmass_message_id"}, + {"resolved": "event_id"}, + ], +} + + +filters = [ + { + "filterkey": "rmass_sent_status", + "operator": "==", + "filtervalue": "fail", + "print": f"Failed to send message to RMASS. Bypassing save during {name}...", + }, + { + "filterkey": "rmass_sent_status", + "operator": "==", + "filtervalue": "error", + "print": f"Failed to send message to RMASS. Bypassing save during {name}...", + }, +] diff --git a/plugins/rmass/actions/synapseassignavatar.py b/plugins/rmass/actions/synapseassignavatar.py index 56d5055..41b38e0 100644 --- a/plugins/rmass/actions/synapseassignavatar.py +++ b/plugins/rmass/actions/synapseassignavatar.py @@ -2,6 +2,13 @@ import os name = "Synapse Assign Avatar" +alias = "synapseassignavatar" + +depends = [ + "getrmassuseravatar", + "rmassavatartosynapse", +] + kind = "action" showstatus = True diff --git a/plugins/rmass/actions/synapseassigndmavatar.py b/plugins/rmass/actions/synapseassigndmavatar.py index c3cd262..f328cb7 100644 --- a/plugins/rmass/actions/synapseassigndmavatar.py +++ b/plugins/rmass/actions/synapseassigndmavatar.py @@ -2,6 +2,15 @@ import os name = "Synapse Assign DM Room Avatar" +alias = "synapseassigndmavatar" + +depends = [ + "getrmassuseravatar", + "rmassavatartosynapse", + "synapsegetroomid", + "synapsecreatedmroom", +] + kind = "action" showstatus = True diff --git a/plugins/rmass/actions/synapseassignusername.py b/plugins/rmass/actions/synapseassignusername.py index 5891b9a..080895f 100644 --- a/plugins/rmass/actions/synapseassignusername.py +++ b/plugins/rmass/actions/synapseassignusername.py @@ -6,6 +6,10 @@ kind = "action" showstatus = True +alias = "synapseassignusername" + +#depends = [] + #astoken = os.environ["AS_TOKEN"] resolve = { diff --git a/plugins/rmass/actions/synapsecreatedmroom.py b/plugins/rmass/actions/synapsecreatedmroom.py index 830b649..0af4adb 100644 --- a/plugins/rmass/actions/synapsecreatedmroom.py +++ b/plugins/rmass/actions/synapsecreatedmroom.py @@ -6,6 +6,10 @@ kind = "action" showstatus = True +alias = "synapsecreatedmroom" + +depends = [] + resolve = { "get": { "sender": ["messageheaders", "userCard", "id"], diff --git a/plugins/rmass/actions/synapsegetlastmessage.py b/plugins/rmass/actions/synapsegetlastmessage.py index 0fa0983..b571eee 100644 --- a/plugins/rmass/actions/synapsegetlastmessage.py +++ b/plugins/rmass/actions/synapsegetlastmessage.py @@ -6,7 +6,6 @@ kind = "action" depends = [ "synapsegetroomalias", - "rmassmessagepush", ] showstatus = True diff --git a/plugins/rmass/actions/synapsegetroomid.py b/plugins/rmass/actions/synapsegetroomid.py index e6157d3..ee749d3 100644 --- a/plugins/rmass/actions/synapsegetroomid.py +++ b/plugins/rmass/actions/synapsegetroomid.py @@ -4,6 +4,12 @@ name = "Synapse Get Room ID" kind = "action" +alias = "synapsegetroomid" + +#depends = [ +# "synapsecreatedmroom", +#] + showstatus = True resolve = { diff --git a/plugins/rmass/actions/synapsepushattachments.py b/plugins/rmass/actions/synapsepushattachments.py index 5b7342e..080fd2e 100644 --- a/plugins/rmass/actions/synapsepushattachments.py +++ b/plugins/rmass/actions/synapsepushattachments.py @@ -2,6 +2,13 @@ from . import synapsenotify name = "Synapse Attachment Push" +alias = "synapsepushattachments" + +depends = [ + "getrmassattachments", + "rmassattachmenttosynapse", +] + kind = "action" showstatus = True diff --git a/plugins/rmass/actions/synapseregister.py b/plugins/rmass/actions/synapseregister.py index e5d9c73..7938a31 100644 --- a/plugins/rmass/actions/synapseregister.py +++ b/plugins/rmass/actions/synapseregister.py @@ -6,6 +6,10 @@ kind = "action" showstatus = True +alias = "synapseregister" + +#depends = [] + resolve = { "get": { "sender": ["messageheaders", "userCard", "id"], diff --git a/plugins/rmass/operations/getrmassconversations.py b/plugins/rmass/operations/getrmassconversations.py index 631f1f0..1859afc 100644 --- a/plugins/rmass/operations/getrmassconversations.py +++ b/plugins/rmass/operations/getrmassconversations.py @@ -3,10 +3,16 @@ from plugins.rmass.operations import synapsepushmessageitems name = "Get RMASS Conversations and Synapse Provisioning" +alias = "getrmassconversations" + +depends = [ + "pullmessagelist", +] + kind = "recursiveset" recursiveset = { - "source": "pullmessages_select", + "source": "pullmessagelist_select", "outputlabel": "messageheaders", "actions": [ synapseregister, diff --git a/plugins/rmass/operations/rmassattachmentpushflow.py b/plugins/rmass/operations/rmassattachmentpushflow.py new file mode 100644 index 0000000..bef83f1 --- /dev/null +++ b/plugins/rmass/operations/rmassattachmentpushflow.py @@ -0,0 +1,20 @@ +from plugins.rmass.actions import rmassmessagepush, savermassmessageid, synapsegetroomalias, refresh_tokens, synapsegetlastmessage, synapsegetattachment, getrmassattachmenturl, synapseattachmenttormass, getrmassattachmentid, rmassattachmentpush + +name = "RMASS Attachment Push" + +alias = "rmassattachmentpushflow" + +depends = [ + "synapsegetroomalias", + "synapsegetlastmessage", +] + +kind = "operation" + +actions = [ + synapsegetattachment, + getrmassattachmenturl, + synapseattachmenttormass, + getrmassattachmentid, + rmassattachmentpush, +] diff --git a/plugins/rmass/operations/rmassmessagepush.py b/plugins/rmass/operations/rmassmessagepush.py index 9979f1e..26faab8 100644 --- a/plugins/rmass/operations/rmassmessagepush.py +++ b/plugins/rmass/operations/rmassmessagepush.py @@ -1,4 +1,5 @@ -from plugins.rmass.actions import rmassmessagepush, synapsegetroomalias, refresh_tokens, synapsegetlastmessage, getrmassconversation, synapsegetattachment, getrmassattachmenturl, synapseattachmenttormass, getrmassattachmentid, rmassattachmentpush +from plugins.rmass.actions import rmassmessagepush, savermassmessageid, synapsegetroomalias, synapsegetlastmessage +from plugins.rmass.operations import rmassattachmentpushflow name = "RMASS Message Push" @@ -9,17 +10,17 @@ recursiveset = { #"retain": False, "outputlabel": "outmessageitem", "actions": [ - #refresh_tokens, synapsegetroomalias, rmassmessagepush, synapsegetlastmessage, - synapsegetattachment, - getrmassattachmenturl, - synapseattachmenttormass, - getrmassattachmentid, - rmassattachmentpush, + #synapsegetattachment, + #getrmassattachmenturl, + #synapseattachmenttormass, + #getrmassattachmentid, + #rmassattachmentpush, + rmassattachmentpushflow, #synapsegetlastmessage, - getrmassconversation, + savermassmessageid, ], }