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,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}...",
|
||||
# },
|
||||
#]
|
||||
Reference in New Issue
Block a user