Successfully built RMASS message push module, sender id resolver from DM room and included processing for 204 HTTP response with no content when handling incoming JSON

This commit is contained in:
Lyncoln
2026-10-17 00:41:52 -04:00
parent b3ac141315
commit d260d3681e
30 changed files with 211 additions and 42 deletions
+3 -2
View File
@@ -4,10 +4,11 @@ from core.execution.action.action import buildAction
from core.runtime.skipstep import skipStep
from core.runtime.recursive import recursiveSet
def buildOperation(definition):
outputs = {}
def buildOperation(definition, outputs):
actions = definition.actions
responses = []
outputs = {}
#outputs = {}
for action in actions:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -3
View File
@@ -11,11 +11,13 @@ def buildLog (action, outputs, response):
except: (KeyError, TypeError)
if action.showstatus is True and response.status_code == 200:
if action.showstatus is True and response.status_code in [200, 204]:
print(f"{action.name} successful")
elif action.showstatus is True and response.status_code != 200:
elif action.showstatus is True and response.status_code not in [200, 204]:
print(f"{action.name} failed with status code {response.status_code}")
try:
print(f"Response: {response.json()["error"]}")
except KeyError:
print(f"Response:", response.json())
return
+7 -5
View File
@@ -1,11 +1,8 @@
import json
def buildOutput(response, action, outputs):
#if select_data != "not applied":
#response_data = select_data
#else:
#response_data = response.json()
if hasattr(action, "outputs"):
if response != None:
try:
response_data = response.json()
except AttributeError:
@@ -23,8 +20,13 @@ def buildOutput(response, action, outputs):
for output_name, response_key in action.outputs.items():
if key == response_key:
outputs[output_name] = value
return outputs
else:
return outputs
#return outputs
+2 -2
View File
@@ -11,8 +11,8 @@ def recursiveSet(definition, outputs):
for job in recursiveset:
outputs, response = buildAction(job, outputs)
#print(outputs["profile"])
#print(outputs["messages"])
print("MESSAGE BODY DEBUG")
print(resolved["messages"])
return outputs
from core.execution.action.action import buildAction
+11
View File
@@ -26,4 +26,15 @@ def resolveItem(action, item):
if resolved[source] == key:
resolved[source] = value
if "deconstruct" in action.resolve:
for source, mutation in action.resolve["deconstruct"].items():
deconstructed = str(resolved[source])
for item in mutation:
deconstructed = deconstructed.replace(str(item), "")
print("DECONSTRUCT TESTING")
print(deconstructed)
resolved[source] = deconstructed
print(resolved["sender"])
return resolved
+2 -2
View File
@@ -17,8 +17,8 @@ def buildSave(action, outputs):
for key, value in save_data.items():
database.execute("""
CREATE TABLE IF NOT EXISTS output_test (
dictionary TEXT NOT NULL UNIQUE,
value TEXT NOT NULL UNIQUE
dictionary TEXT PRIMARY KEY,
value TEXT NOT NULL
)
""")
Binary file not shown.
+15 -5
View File
@@ -5,7 +5,10 @@ from http.server import HTTPServer, BaseHTTPRequestHandler
from .dispatcher import dispatchRequest
from .createresponse import buildResponse
from core.runtime.outputs import buildOutput
from core.runtime.resolver import resolveItem
from plugins.rmass.listeners import synapselistener
from plugins.rmass.operations import rmassmessagepush
from core.execution.operation import buildOperation
port = int(os.environ.get("SERVER_PORT", 19001))
@@ -104,13 +107,20 @@ class RequestHandler(BaseHTTPRequestHandler):
request = json.loads(data)
requestjson = json.dumps(request, indent=4)
print (request)
print(requestjson)
#print (request)
#print(requestjson)
for event in request["events"]:
if "state_key" in event:
# Room state event
continue
if event.get("type") == "m.room.message":
# Process the message
print (event)
outputs = buildOutput(data, synapselistener, outputs)
print (outputs)
#resolved =
#outputs = buildOperation(listener, outputs, resolved)
#print (event)
outputs = buildOperation(rmassmessagepush, outputs)
self.send_response(200)
self.send_header("Content-Type", "application/json")
+3 -1
View File
@@ -1,5 +1,7 @@
from plugins import rmass
from core.execution.operation import buildOperation
outputs = buildOperation(rmass.operations.login)
outputs = {}
outputs = buildOperation(rmass.operations.login, outputs)
+1 -1
View File
@@ -1 +1 @@
from . import actions, operations, inbound
from . import actions, operations, listeners
Binary file not shown.
+70
View File
@@ -0,0 +1,70 @@
name = "RMASS Message Push"
kind = "action"
showstatus = True
#recursive = {
# "source": "events",
# "reverse": False,
# "label": "outmessageitem",
#}
#Resolve sources its data from outputs. Ensure keys are in outputs
resolve = {
"get": {
"sender": ["room_name"],
"event_id": ["outmessageitem", "event_id"],
"message_body": ["outmessageitem", "content", "body"],
#"room_id": ["outmessageitem", "room_id"],
"timestamp": ["outmessageitem", "origin_server_ts"],
},
# "construct": {
# "matrixuser": [
# "@rmass_",
# {"resolved": "sender"},
# ":loxthelion.com",
# ],
# },
# "transform": {
# "matrixuser": {
# "@lyncoln:loxthelion.com": "@rmass_238302:loxthelion.com",
# },
# },
"deconstruct": {
"sender" : [
"#rmass_dm_",
":loxthelion.com",
],
},
}
keys = [
{
"keytitle": "message",
"keyvalue": {
"resolved": "message_body",
},
},
{
"keytitle": "profileId",
"keyvalue": {
"resolved": "sender",
},
},
]
method = "POST"
path = [
"https://rentmasseur.com/api/v1/mailbox",
]
headers = {
"Authorization": {
"output": "access_token",
"prefix": "Bearer ",
},
}
@@ -0,0 +1,54 @@
name = "Get Synapse Room Alias"
kind = "action"
showstatus = True
#recursive = {
# "source": "getmessage",
# "reverse": True,
# "label": "messageitem",
#}
resolve = {
"get": {
#"sender": ["messageitem", "senderId"],
#"event_id": ["messageitem", "id"],
#"message_body": ["events", 0, "content", "body"],
"room_id": ["outmessageitem", "room_id"],
#"timestamp": ["events", 0, "original_server_ts"],
},
# "construct": {
# "matrixuser": [
# "@rmass_",
# {"resolved": "sender"},
# ":loxthelion.com",
# ],
# },
# "transform": {
# "matrixuser": {
# "@lyncoln:loxthelion.com": "@rmass_238302:loxthelion.com",
# },
# },
}
method = "GET"
path = [
"https://loxthelion.com/_matrix/client/v3/rooms/",
{"resolved": "room_id"},
"/state/m.room.canonical_alias",
]
headers = {
"Authorization": {
"os": "ADMIN_TOKEN",
"prefix": "Bearer ",
},
"Content-Type": "application/json",
}
outputs = {
"room_name": "alias"
}
+1 -1
View File
@@ -1,4 +1,4 @@
import os
#import os
name = "Synapse Message Push"
+1 -1
View File
@@ -1 +1 @@
from . import receive
from . import synapselistener
@@ -0,0 +1,17 @@
from plugins.rmass.actions import rmassmessagepush, synapsegetroomalias, refresh_tokens
name = "RMASS Message Push"
kind = "operation"
actions = [
#Recursiveset is used to reference a nested operation inside an operation whose actions are listed in the recursiveset action list
"recursiveset",
]
recursiveset = {
"source": "events",
"outputlabel": "outmessageitem",
"actions": [synapsegetroomalias, refresh_tokens, rmassmessagepush],
}
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwNDA4ODgsIm5iZiI6MTc5MjA0MDcwOCwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjA0MDc2OH0.8twTKQb2OG-OfT_C2eAwD2OpV__X7S-MWnpVXdLeLvBzfZcW6ZJLesvSqgYXeO56yn-_UblIUEwfy_B8EuDTSw", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ2MzI3NjgsIm5iZiI6MTc5MjA0MDcwOCwianRpIjoiUXRjRXE2TWtGdWhHNjdiTHdLak1kdzJXazIzMlFtVkp4K2J3aGs2RTlCZz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjA0MDc2OCwic3ViIjoiMjM4MzAyIn0.zmQ9S08NHgr2q0g3VloTgY3xBjATxXk2mdg6MbeHjuQ47OZ24E8bBNyRaqDJYJ0OnCkF5CvepJ5ISlnvkqTPRA"}
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIyMTE4NzEsIm5iZiI6MTc5MjIxMTY5MSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjIxMTc1MX0.yPPrAkT6ZnR9Y3rLhUkWSgL6X_I0UuKznujBg2L-UkI3kGPZbe2G4ADSZBq0DGxiAVnmglwbhXZHs6QuHwIOTQ", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ4MDM3NTEsIm5iZiI6MTc5MjIxMTY5MSwianRpIjoia3FxVjB1dEpnRDM4V2MwNnE1b0l2Mkx6SGJGYTVKcjM2aHRtZUQxRk1vVT0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjIxMTc1MSwic3ViIjoiMjM4MzAyIn0.4QG6fWWAwzvmox4QmWmcP6bIS6pA7Vi2srsppplI0BDXI2NWbigxfswrTrmb1-QI7PpB9azHDP7Xt_gY_6_pnA"}
+2 -2
View File
@@ -2,6 +2,6 @@ from plugins import rmass
from core.execution.operation import buildOperation
outputs = buildOperation(rmass.operations.synapsemessagepush)
outputs = {}
outputs = buildOperation(rmass.operations.synapsemessagepush, outputs)