122 lines
2.7 KiB
Python
122 lines
2.7 KiB
Python
import os
|
|
|
|
from . import synapsenotify
|
|
|
|
name = "RMASS Message Push"
|
|
|
|
alias = "rmassmessagepush"
|
|
|
|
depends = [
|
|
"synapsegetroomalias",
|
|
"synapsegetlastmessage",
|
|
]
|
|
|
|
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"],
|
|
#"matrix_sender": ["outmessageitem", "sender"],
|
|
#"attachment": ["outmessageitem", "url"],
|
|
#"msg_type": ["outmessageitem", "type"],
|
|
#"echo_tag": ["outmessageitem", "content", "com.loxthelion.rmass_message_id"],
|
|
},
|
|
"deconstruct": {
|
|
"rmass_user" : [
|
|
"#rmass_dm_",
|
|
":loxthelion.com",
|
|
],
|
|
},
|
|
}
|
|
|
|
keys = [
|
|
{
|
|
"keytitle": "message",
|
|
"keyvalue": {
|
|
"resolved": "message_body",
|
|
},
|
|
},
|
|
{
|
|
"keytitle": "profileId",
|
|
"keyvalue": {
|
|
"resolved": "rmass_user",
|
|
},
|
|
},
|
|
]
|
|
|
|
method = "POST"
|
|
|
|
path = [
|
|
"https://rentmasseur.com/api/v1/mailbox",
|
|
]
|
|
|
|
headers = {
|
|
"Authorization": {
|
|
"output": "access_token",
|
|
"prefix": "Bearer ",
|
|
},
|
|
}
|
|
|
|
loaddata = [
|
|
"access_token",
|
|
"refresh_token",
|
|
]
|
|
|
|
savepath = os.environ["TOKEN_STORE"]
|
|
|
|
responsepolicy = [
|
|
{
|
|
"statuscode": 400,
|
|
"print": "Message is too short. Notifying...",
|
|
"execute": synapsenotify,
|
|
"response_update": False,
|
|
}
|
|
]
|
|
|
|
outputs = {
|
|
"rmass_sent_status": "status"
|
|
}
|
|
|
|
##Filter test against recursiveset
|
|
|
|
filters = [
|
|
{
|
|
"filterkey": "msgtype",
|
|
"operator": "==",
|
|
"filtervalue": "m.image",
|
|
"print": f"Image detected. Pushing attachment",
|
|
},
|
|
{
|
|
"filterkey": "event_id",
|
|
"operator": "==",
|
|
"filtervalue": {"outputs": "db_event_id"},
|
|
"print": f"Message already delivered. Bypassing {name}",
|
|
},
|
|
# {
|
|
# "filterkey": "matrix_sender",
|
|
# "operator": "!=",
|
|
# "filtervalue": "@lyncoln:loxthelion.com",
|
|
# "print": f"Excluding message loop item during {name}",
|
|
# },
|
|
# {
|
|
# "filterkey": "msg_type",
|
|
# "operator": "!=",
|
|
# "filtervalue": "m.room.message",
|
|
# "print": f"Excluding non-room message event during {name}",
|
|
# },
|
|
# {
|
|
# "filterkey": "echo_tag",
|
|
# "operator": "is not",
|
|
# "filtervalue": None,
|
|
# "print": f"Excluding imported message event during {name}",
|
|
# },
|
|
]
|