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:
Lyncoln
2026-10-24 21:03:03 -04:00
parent ad80289675
commit 7b949ec004
11 changed files with 308 additions and 11 deletions
@@ -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...",
# },
#]
+11 -2
View File
@@ -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": [