Files
rmmanager/plugins/rmass/actions/getrmassconversation.py
T

95 lines
2.1 KiB
Python

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}...",
},
]