diff --git a/plugins/rmass/actions/getrmassattachmentid.py b/plugins/rmass/actions/getrmassattachmentid.py new file mode 100644 index 0000000..854cfe3 --- /dev/null +++ b/plugins/rmass/actions/getrmassattachmentid.py @@ -0,0 +1,44 @@ +name = "Get RMASS Message Attachment ID" + +kind = "action" + +alias = "getrmassattachmentid" + +showstatus = True + +resolve = { + "get": { + "path": ["lastmessage", 0, "content", "com.loxthelion.rmass_message_id"], + "msgtype": ["outmessageitem", "content", "msgtype"], + } +} + +isrequest = True + +method = "GET" + +path = [ + "https://rentmasseur.com/api/v1/mailbox/", + {"resolved": "path"}, + "/attachments" +] + +outputs = { + "rmass_attachment_id": "id" +} + +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + +filters = [ + { + "filterkey": "msgtype", + "operator": "==", + "filtervalue": "m.text", + "print": f"No image detected. Bypassing attachment push", + }, +] \ No newline at end of file diff --git a/plugins/rmass/actions/getrmassattachmenturl.py b/plugins/rmass/actions/getrmassattachmenturl.py new file mode 100644 index 0000000..545410c --- /dev/null +++ b/plugins/rmass/actions/getrmassattachmenturl.py @@ -0,0 +1,50 @@ +name = "Get RMASS Message Attachment URL" + +kind = "action" + +alias = "getrmassattachmenturl" + +showstatus = True + +resolve = { + "get": { + "path": ["lastmessage", 0, "content", "com.loxthelion.rmass_message_id"], + "msgtype": ["outmessageitem", "content", "msgtype"], + } +} + +isrequest = True + +method = "GET" + +#loaddata = [ +# "access_token", +# "refresh_token", +#] + +#savepath = os.environ["TOKEN_STORE"] + +path = [ + "https://rentmasseur.com/api/v1/media/upload?mediaType=30&conversationId=", + {"resolved": "path"}, +] + +outputs = { + "uploadurl": "url" +} + +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + +filters = [ + { + "filterkey": "msgtype", + "operator": "==", + "filtervalue": "m.text", + "print": f"No image detected. Bypassing attachment push", + }, +] \ No newline at end of file diff --git a/plugins/rmass/actions/rmassattachmentpush.py b/plugins/rmass/actions/rmassattachmentpush.py new file mode 100644 index 0000000..e1a9e94 --- /dev/null +++ b/plugins/rmass/actions/rmassattachmentpush.py @@ -0,0 +1,89 @@ +import os + +from . import synapsenotify + +name = "RMASS Attachment Push" + +kind = "action" + +showstatus = True + +#Resolve sources its data from outputs. Ensure keys are in outputs +resolve = { + "get": { + "rmass_user": ["room_alias"], + #"event_id": ["outmessageitem", "event_id"], + "message_body": ["outmessageitem", "content", "body"], + "msgtype": ["outmessageitem", "content", "msgtype"], + "room_id": ["outmessageitem", "room_id"], + #"timestamp": ["outmessageitem", "origin_server_ts"], + "rmass_attach": ["response_list", 0, "id"], + "path": ["lastmessage", 0, "content", "com.loxthelion.rmass_message_id"], + #"attachment": ["outmessageitem", "url"], + #"msg_type": ["outmessageitem", "type"], + #"echo_tag": ["outmessageitem", "content", "com.loxthelion.rmass_message_id"], + }, + "deconstruct": { + "rmass_user" : [ + "#rmass_dm_", + ":loxthelion.com", + ], + }, + "construct": { + "rmass_attach" : [ + "a_", + {"resolved": "rmass_attach"}, + ], + }, +} + +keys = [ + #{ + # "keytitle": "message", + # "keyvalue": { + # "resolved": "message_body", + # }, + #}, + { + "keytitle": "message", + "keyvalue": "Here's a photo!", + }, + #{ + # "keytitle": "profileId", + # "keyvalue": { + # "resolved": "rmass_user", + # }, + #}, + { + "keytitle": "attachmentIds", + "keyvalue": { + "resolved": "rmass_attach", + }, + }, +] + +method = "POST" + +path = [ + "https://rentmasseur.com/api/v1/mailbox/", + {"resolved": "path"}, +] + +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + + +##Filter test against recursiveset + +filters = [ + { + "filterkey": "msgtype", + "operator": "==", + "filtervalue": "m.text", + "print": f"No image detected. Bypassing attachment push", + }, +] \ No newline at end of file diff --git a/plugins/rmass/actions/synapseattachmenttormass.py b/plugins/rmass/actions/synapseattachmenttormass.py new file mode 100644 index 0000000..a866e76 --- /dev/null +++ b/plugins/rmass/actions/synapseattachmenttormass.py @@ -0,0 +1,59 @@ +name = "Upload Attachments to RMASS" + +kind = "action" + +alias = "uploadrmassattachment" + +showstatus = True + +isrequest = True + +resolve = { + "get": { + "uploadurl": ["uploadurl"], + "msgtype": ["outmessageitem", "content", "msgtype"], + "rmass_user": ["room_alias"], + "path": ["lastmessage", 0, "content", "com.loxthelion.rmass_message_id"], + }, + "deconstruct": { + "rmass_user" : [ + "#rmass_dm_", + ":loxthelion.com", + ], + }, +} + +method = "POST" + +#To add resolution suffix, second item must be a dictionary. References the "path" library under resolved +path = [ + {"resolved": "uploadurl"}, +] + +headers = { + "Authorization": { + "output": "access_token", + "prefix": "Bearer ", + }, +} + +requestfile = "synapse_attachment" + +requestdata = { + "mediaType": "30", + "emailId": {"resolved": "path"} +} + +outputs = { + "rmass_uploaded_image": "url", + "mediaId": "mediaId" +} + +filters = [ + { + "filterkey": "msgtype", + "operator": "==", + "filtervalue": "m.text", + "print": f"No image detected. Bypassing attachment push", + }, +] diff --git a/plugins/rmass/actions/synapsegetattachment.py b/plugins/rmass/actions/synapsegetattachment.py new file mode 100644 index 0000000..da772eb --- /dev/null +++ b/plugins/rmass/actions/synapsegetattachment.py @@ -0,0 +1,59 @@ +name = "Get Synapse Attachment" + +kind = "action" + +showstatus = True + +alias = "getsynapseattachment" + +## PRE-RUNTIME ACTIONS + +resolve = { + "get": { + "room_id": ["outmessageitem", "room_id"], +# "matrix_sender": ["outmessageitem", "sender"], + "msgtype": ["outmessageitem", "content", "msgtype"], + "synapse_image": ["outmessageitem", "content", "url"], + }, + "deconstruct": { + "synapse_image" : [ + #"#rmass_dm_", + "mxc://loxthelion.com/", + ], + }, +} + +## RUNTIME ACTIONS + +isrequest = True + +method = "GET" + +path = [ + #"https://loxthelion.com/_matrix/client/v3/rooms/", + "https://loxthelion.com/_matrix/client/v1/media/download/loxthelion.com/", + {"resolved": "synapse_image"}, + #"/state/m.room.canonical_alias", + #"?user_id=%40rmass_bridge%3Aloxthelion.com" +] + +headers = { + "Authorization": { + "os": "AS_TOKEN", + "prefix": "Bearer ", + }, + "Content-Type": "application/json", +} + +## POST-RUNTIME ACTIONS + +image = "synapse_attachment" + +filters = [ + { + "filterkey": "msgtype", + "operator": "==", + "filtervalue": "m.text", + "print": f"No image detected. Bypassing attachment push", + }, +]