Improved recursive handling by nesting operations in operations under then new buildRecursive. Also changed extract module to attach its findings to outputs for better resolver and recursiveSet targeting.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
name = "Get RMASS Message Attachments"
|
||||
|
||||
kind = "action"
|
||||
|
||||
alias = "getrmassattachment"
|
||||
|
||||
showstatus = True
|
||||
|
||||
resolve = {
|
||||
"get": {
|
||||
"attachment_path": ["attachment_item", "original"],
|
||||
}
|
||||
}
|
||||
|
||||
isrequest = False
|
||||
|
||||
method = "GET"
|
||||
|
||||
path = [
|
||||
{"resolved": "attachment_path"},
|
||||
]
|
||||
|
||||
image = "message_attachment"
|
||||
|
||||
#filters = [
|
||||
# {
|
||||
# "filterkey": "attachment_list",
|
||||
# "operator": "is",
|
||||
# "filtervalue": None,
|
||||
# "print": "No attachments detected. Continuing...",
|
||||
# },
|
||||
#]
|
||||
@@ -62,7 +62,16 @@ saverow = {
|
||||
],
|
||||
|
||||
"rowitems": [
|
||||
{"resolved": "rmass_message_id"},
|
||||
{"outputs": "rmass_message_id"},
|
||||
{"resolved": "event_id"},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
#filters = [
|
||||
# {
|
||||
# "filterkey": "rmass_sent_status",
|
||||
# "operator": "==",
|
||||
# "filtervalue": "fail",
|
||||
# "print": "Failed to send message to RMASS. Continuing...",
|
||||
# },
|
||||
#]
|
||||
@@ -0,0 +1,48 @@
|
||||
name = "Upload Attachments to Synapse"
|
||||
|
||||
kind = "action"
|
||||
|
||||
alias = "uploadattachment"
|
||||
|
||||
showstatus = True
|
||||
|
||||
#resolve = {
|
||||
# "get": {
|
||||
#"sender": ["messageheaders", "userCard", "id"],
|
||||
#"avatar": ["uploadimage"],
|
||||
#"username": ["messageheaders", "userCard", "username"],
|
||||
#"avatar_hash": ["useravatar_hash"],
|
||||
# },
|
||||
#}
|
||||
|
||||
isrequest = True
|
||||
|
||||
method = "POST"
|
||||
|
||||
#To add resolution suffix, second item must be a dictionary. References the "path" library under resolved
|
||||
path = [
|
||||
"https://loxthelion.com/_matrix/media/v3/upload?filename=attachment.jpg",
|
||||
]
|
||||
|
||||
headers = {
|
||||
"Authorization": {
|
||||
"os": "AS_TOKEN",
|
||||
"prefix": "Bearer ",
|
||||
},
|
||||
"Content-Type": "image/jpeg",
|
||||
}
|
||||
|
||||
requestdata = "message_attachment"
|
||||
|
||||
outputs = {
|
||||
"uploadattachment": "content_uri",
|
||||
}
|
||||
|
||||
#filters = [
|
||||
# {
|
||||
# "filterkey": "message_attachment",
|
||||
# "operator": "is",
|
||||
# "filtervalue": None,
|
||||
# "print": f"No attachments. Skipping {name}...",
|
||||
# },
|
||||
#]
|
||||
@@ -0,0 +1,150 @@
|
||||
from . import synapsenotify
|
||||
|
||||
name = "Synapse Attachment Push"
|
||||
|
||||
kind = "action"
|
||||
|
||||
showstatus = True
|
||||
|
||||
#recursive = {
|
||||
# "source": "getmessage_select",
|
||||
# "reverse": True,
|
||||
# "label": "messageitem",
|
||||
#}
|
||||
|
||||
resolve = {
|
||||
"get": {
|
||||
"sender": ["messageitem", "senderId"],
|
||||
"attachment_id": ["attachment_item", "id"],
|
||||
#"message_body": ["messageitem", "text"],
|
||||
"room_id": ["room_id"],
|
||||
"timestamp": ["messageitem", "createdAt"],
|
||||
"attachmenturl": ["uploadattachment"],
|
||||
},
|
||||
"construct": {
|
||||
"matrixuser": [
|
||||
"@rmass_",
|
||||
{"resolved": "sender"},
|
||||
":loxthelion.com",
|
||||
],
|
||||
},
|
||||
"transform": {
|
||||
"matrixuser": {
|
||||
"@rmass_238302:loxthelion.com": "@lyncoln:loxthelion.com",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
isrequest = True
|
||||
|
||||
keys = [
|
||||
{
|
||||
"keytitle": "msgtype",
|
||||
"keyvalue": "m.image",
|
||||
},
|
||||
{
|
||||
"keytitle": "body",
|
||||
"keyvalue": "attachment.jpg",
|
||||
},
|
||||
{
|
||||
"keytitle": "url",
|
||||
"keyvalue": {
|
||||
"resolved": "attachmenturl",
|
||||
},
|
||||
},
|
||||
{
|
||||
"keytitle": "info",
|
||||
"keyvalue": {
|
||||
"mimetype": "image/jpeg",
|
||||
},
|
||||
},
|
||||
{
|
||||
"keytitle": "com.loxthelion.rmass_message_id",
|
||||
"keyvalue": {
|
||||
"resolved": "attachment_id",
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
method = "PUT"
|
||||
|
||||
path = [
|
||||
"https://loxthelion.com/_matrix/client/v3/rooms/",
|
||||
{"resolved": "room_id"},
|
||||
"/send/m.room.message/",
|
||||
{"resolved": "attachment_id"},
|
||||
"?user_id=",
|
||||
{"resolved": "matrixuser"},
|
||||
"&ts=",
|
||||
{"resolved": "timestamp"},
|
||||
"000"
|
||||
]
|
||||
|
||||
headers = {
|
||||
"Authorization": {
|
||||
"os": "AS_TOKEN",
|
||||
"prefix": "Bearer ",
|
||||
},
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
#outputs = {
|
||||
# "event_id": "event_id"
|
||||
#}
|
||||
|
||||
#extract = {
|
||||
# "get": {
|
||||
# "attachment_list": ["messageitem", "attachments"],
|
||||
# },
|
||||
#}
|
||||
|
||||
#saverow = {
|
||||
# "table": "message_mapping",
|
||||
# "columns": [
|
||||
# {"rmass_message_id": "INTEGER PRIMARY KEY"},
|
||||
# {"matrix_event_id": "TEXT NOT NULL UNIQUE"},
|
||||
# ],
|
||||
#
|
||||
# "rowitems": [
|
||||
# {"resolved": "attachment_id"},
|
||||
# {"outputs": "event_id"},
|
||||
# ],
|
||||
#}
|
||||
|
||||
#readrow = {
|
||||
# "table": "message_mapping",
|
||||
# "columns": [
|
||||
# {"rmass_message_id": "INTEGER PRIMARY KEY"},
|
||||
# {"matrix_event_id": "TEXT NOT NULL UNIQUE"},
|
||||
# ],
|
||||
# "searchcolumn": "rmass_message_id",
|
||||
# "rowsearchvalue": [
|
||||
# {"resolved": "attachment_id"},
|
||||
# ],
|
||||
# "export": {
|
||||
# 0: "db_message_id",
|
||||
# }
|
||||
#}
|
||||
|
||||
#filters = [
|
||||
# {
|
||||
# "filterkey": "attachment_id",
|
||||
# "operator": "==",
|
||||
# "filtervalue": {"outputs": "db_message_id"},
|
||||
# "print": "Message already forwarded. Continuing...",
|
||||
# },
|
||||
## To be uncommented once getrmassattachments is introduced
|
||||
# {
|
||||
# "filterkey": "attachments",
|
||||
# "operator": "is not",
|
||||
# "filtervalue": None,
|
||||
# "print": "Getting message attachments...",
|
||||
# "execute": "getrmassattachments"
|
||||
# },
|
||||
# {
|
||||
# "filterkey": "room_id",
|
||||
# "operator": "is",
|
||||
# "filtervalue": None,
|
||||
# "print": f"DM room is unavailable. Skipping {name}...",
|
||||
# },
|
||||
#]
|
||||
@@ -92,6 +92,12 @@ outputs = {
|
||||
"event_id": "event_id"
|
||||
}
|
||||
|
||||
extract = {
|
||||
"get": {
|
||||
"attachment_list": ["messageitem", "attachments"],
|
||||
},
|
||||
}
|
||||
|
||||
saverow = {
|
||||
"table": "message_mapping",
|
||||
"columns": [
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from plugins.rmass.actions import getmessage, synapseregister, synapseassignusername, getrmassuseravatar, rmassavatartosynapse, synapseassignavatar, synapsecreatespace, synapsegetspaceid, synapsecreatedmroom, synapseassigndmavatar, synapsegetroomid, synapseassignspace#, synapsepushmessages
|
||||
from plugins.rmass.operations import synapsepushmessages
|
||||
|
||||
name = "Get RMASS Conversations and Synapse Provisioning"
|
||||
|
||||
kind = "recursiveset"
|
||||
|
||||
recursiveset = {
|
||||
"source": "pullmessages_select",
|
||||
"outputlabel": "messageheaders",
|
||||
"actions": [
|
||||
synapseregister,
|
||||
synapseassignusername,
|
||||
getrmassuseravatar,
|
||||
rmassavatartosynapse,
|
||||
synapseassignavatar,
|
||||
getmessage,
|
||||
#synapsecreatespace,
|
||||
#synapsegetspaceid,
|
||||
synapsecreatedmroom,
|
||||
synapsegetroomid,
|
||||
synapseassigndmavatar,
|
||||
#synapseassignspace,
|
||||
synapsepushmessages,
|
||||
],
|
||||
}
|
||||
@@ -10,7 +10,7 @@ actions = [
|
||||
refresh_tokens,
|
||||
pullmessagelist,
|
||||
getrmassconversations,
|
||||
synapsepushmessages,
|
||||
#synapsepushmessages,
|
||||
]
|
||||
|
||||
#recursiveset = {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
from plugins.rmass.actions import synapsepushmessages, synapsepushattachments, getrmassattachments, rmassattachmenttosynapse
|
||||
|
||||
kind = "recursiveset"
|
||||
|
||||
name = "Synapse Attachment Push Recursive Set"
|
||||
|
||||
recursiveset = {
|
||||
"source": "attachment_list",
|
||||
"reverse": False,
|
||||
"retain": False,
|
||||
"outputlabel": "attachment_item",
|
||||
"actions": [
|
||||
getrmassattachments,
|
||||
rmassattachmenttosynapse,
|
||||
synapsepushattachments,
|
||||
],
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
from plugins.rmass.actions import synapsepushmessages
|
||||
from plugins.rmass.actions import synapsepushmessages
|
||||
from plugins.rmass.operations import synapsepushattachments
|
||||
|
||||
kind = "recursiveset"
|
||||
|
||||
@@ -10,5 +11,6 @@ recursiveset = {
|
||||
"outputlabel": "messageitem",
|
||||
"actions": [
|
||||
synapsepushmessages,
|
||||
synapsepushattachments,
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user