Fixed HTML message formatting, Extended resolver for get, construct and transform functions, Added entire message history with aliasing for personal matrix account

This commit is contained in:
Lyncoln
2026-10-15 14:37:17 -04:00
parent 61ee8145ae
commit b5e6d4eaea
28 changed files with 169 additions and 66 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ def buildAction (action, outputs):
if hasattr(action, "recursive"): if hasattr(action, "recursive"):
items = outputs[action.recursive["source"]] items = outputs[action.recursive["source"]]
reverse = action.recursive.get("reversed", False) reverse = action.recursive.get("reverse", False)
if reverse: if reverse:
items = reversed(items) items = reversed(items)
Binary file not shown.
+19 -1
View File
@@ -1,11 +1,29 @@
def resolveItem(action, item): def resolveItem(action, item):
resolved = {} resolved = {}
if hasattr(action, "resolve"): if hasattr(action, "resolve"):
for label, keys in action.resolve.items(): for label, keys in action.resolve["get"].items():
target = item target = item
for key in keys: for key in keys:
target = target[key] target = target[key]
resolved[label] = target resolved[label] = target
if "construct" in action.resolve:
for label2, piece in action.resolve["construct"].items():
constructed = ""
for item in piece:
if isinstance(item, dict):
for key, value in item.items():
item = resolved[value]
constructed += str(item)
resolved[label2] = constructed
if "transform" in action.resolve:
for source, mutation in action.resolve["transform"].items():
for key, value in mutation.items():
if resolved[source] == key:
resolved[source] = value
return resolved return resolved
Binary file not shown.
+21 -4
View File
@@ -8,7 +8,28 @@ from .createresponse import buildResponse
port = int(os.environ.get("SERVER_PORT", 19001)) port = int(os.environ.get("SERVER_PORT", 19001))
from http.server import HTTPServer, BaseHTTPRequestHandler
class RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
print("POST request received")
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(b'{"status": "ok"}')
def startServer(): def startServer():
server = HTTPServer(("127.0.0.1", port), RequestHandler)
print(f"Server listening on port {port}")
server.serve_forever()
def startServer2():
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("0.0.0.0", port)) server.bind(("0.0.0.0", port))
@@ -22,10 +43,6 @@ def startServer():
print("Accepting connections") print("Accepting connections")
connection.settimeout(30) connection.settimeout(30)
class RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
print("POST request received")
try: try:
while True: while True:
data = connection.recv(4096) data = connection.recv(4096)
+4 -7
View File
@@ -8,18 +8,15 @@ method = "GET"
#Used to resolve path for recursive handling. Path location must match the location of the recursiveset data from pullmessage operation #Used to resolve path for recursive handling. Path location must match the location of the recursiveset data from pullmessage operation
resolve = { resolve = {
"get": {
"path": ["messageheaders", "id"], "path": ["messageheaders", "id"],
}
} }
#To add resolution suffix, second item must be a dictionary. References the "path" library under resolved #To add resolution suffix, second item must be a dictionary. References the "path" library under resolved
path = [ path = [
"https://rentmasseur.com/api/v1/mailbox/", "https://rentmasseur.com/api/v1/mailbox/",
{"resolved": "path"}, {"resolved": "path"},
#{
# "output": "id",
# #"keys": [0, "id"]
# "keys": "id"
#}
] ]
headers = { headers = {
@@ -41,8 +38,8 @@ select = {
"value": False, "value": False,
}, },
"exclude": { "exclude": {
"key": "senderId", "key": {},
"value": 238302, "value": {},
} }
} }
-2
View File
@@ -18,8 +18,6 @@ headers = {
}, },
} }
#domainname="rentmasseur.com"
cookies = { cookies = {
"accessToken": { "accessToken": {
"output": "access_token", "output": "access_token",
@@ -7,11 +7,14 @@ kind = "action"
showstatus = True showstatus = True
resolve = { resolve = {
"get": {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
"space_id": ["space_id"], "space_id": ["space_id"],
"username": ["profile", "username"], "username": ["profile", "username"],
"room_id": ["dmroom_id"], "room_id": ["dmroom_id"],
},
} }
keys = [ keys = [
{ {
"keytitle": "via", "keytitle": "via",
+14 -5
View File
@@ -9,9 +9,19 @@ showstatus = True
astoken = os.environ["AS_TOKEN"] astoken = os.environ["AS_TOKEN"]
resolve = { resolve = {
"get": {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
"username": ["profile", "username"], "username": ["profile", "username"],
},
"construct": {
"matrixuser": [
"@rmass_",
{"resolved": "sender"},
":loxthelion.com",
],
},
} }
keys = [ keys = [
{ {
"keytitle": "displayname", "keytitle": "displayname",
@@ -24,11 +34,10 @@ keys = [
method = "PUT" method = "PUT"
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/profile/@rmass_", "https://loxthelion.com/_matrix/client/v3/profile/",
{"resolved": "sender"}, {"resolved": "matrixuser"},
":loxthelion.com/displayname?user_id=@rmass_", "/displayname?user_id=",
{"resolved": "sender"}, {"resolved": "matrixuser"},
":loxthelion.com"
] ]
headers = { headers = {
+17 -5
View File
@@ -7,8 +7,21 @@ kind = "action"
showstatus = True showstatus = True
resolve = { resolve = {
"get": {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
"username": ["profile", "username"], "username": ["profile", "username"],
},
"construct": {
"matrixuser": [
"@rmass_",
{"resolved": "sender"},
":loxthelion.com",
],
"matrixdm": [
"rmass_dm_",
{"resolved": "sender"},
],
},
} }
keys = [ keys = [
@@ -21,8 +34,7 @@ keys = [
{ {
"keytitle": "room_alias_name", "keytitle": "room_alias_name",
"keyvalue": { "keyvalue": {
"resolved": "sender", "resolved": "matrixdm",
"prefix": "rmass_dm_",
}, },
}, },
{ {
@@ -55,9 +67,9 @@ keys = [
method = "POST" method = "POST"
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_", "https://loxthelion.com/_matrix/client/v3/createRoom?user_id=",
{"resolved": "sender"}, {"resolved": "matrixuser"},
":loxthelion.com", #":loxthelion.com",
] ]
headers = { headers = {
+14 -9
View File
@@ -7,11 +7,19 @@ kind = "action"
showstatus = True showstatus = True
resolve = { resolve = {
"sender": ["messages", 0, "senderId"], "get": {
#"messageid": ["message", "id"], #"sender": ["messages", 0, "senderId"],
"username": ["profile", "username"], #"username": ["profile", "username"],
"locationname": ["profile", "location"], "locationname": ["profile", "location"],
"locationcode": ["profile", "searchCity"], "locationcode": ["profile", "searchCity"],
},
"construct": {
"matrixspacealias": [
"rmass_space_",
{"resolved": "locationcode"},
#"%3Aloxthelion.com",
],
},
} }
keys = [ keys = [
{ {
@@ -23,8 +31,8 @@ keys = [
{ {
"keytitle": "room_alias_name", "keytitle": "room_alias_name",
"keyvalue": { "keyvalue": {
"resolved": "locationcode", "resolved": "matrixspacealias",
"prefix": "rmass_space_", #"prefix": "rmass_space_",
}, },
}, },
{ {
@@ -46,7 +54,7 @@ keys = [
#"keyvalue": { #"keyvalue": {
#"users": { #"users": {
#"@lyncoln:loxthelion.com": 100, #"@lyncoln:loxthelion.com": 100,
#"@rmass_:loxthelion.com": 100, #"@rmass_*:loxthelion.com": 100,
#}, #},
#}, #},
#} #}
@@ -55,9 +63,6 @@ keys = [
method = "POST" method = "POST"
path = [ path = [
#"https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_",
#{"resolved": "sender"},
#":loxthelion.com",
"https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_bridge:loxthelion.com" "https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_bridge:loxthelion.com"
] ]
+11 -3
View File
@@ -7,15 +7,23 @@ kind = "action"
showstatus = True showstatus = True
resolve = { resolve = {
"get": {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
},
"construct": {
"matrixdm": [
"%23rmass_dm_",
{"resolved": "sender"},
"%3Aloxthelion.com",
],
},
} }
method = "GET" method = "GET"
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_dm_", "https://loxthelion.com/_matrix/client/v3/directory/room/",
{"resolved": "sender"}, {"resolved": "matrixdm"},
"%3Aloxthelion.com",
] ]
headers = { headers = {
+11 -4
View File
@@ -7,16 +7,23 @@ kind = "action"
showstatus = True showstatus = True
resolve = { resolve = {
"sender": ["messages", 0, "senderId"], "get": {
"locationcode": ["profile", "searchCity"], "locationcode": ["profile", "searchCity"],
},
"construct": {
"matrixspace": [
"%23rmass_space_",
{"resolved": "locationcode"},
"%3Aloxthelion.com",
],
},
} }
method = "GET" method = "GET"
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_space_", "https://loxthelion.com/_matrix/client/v3/directory/room/",
{"resolved": "locationcode"}, {"resolved": "matrixspace"},
"%3Aloxthelion.com",
] ]
headers = { headers = {
+29 -3
View File
@@ -13,12 +13,27 @@ recursive = {
} }
resolve = { resolve = {
"get": {
"sender": ["messageitem", "senderId"], "sender": ["messageitem", "senderId"],
"message_id": ["messageitem", "id"], "message_id": ["messageitem", "id"],
"message_body": ["messageitem", "text"], "message_body": ["messageitem", "text"],
"room_id": ["dmroom_id"], "room_id": ["dmroom_id"],
"timestamp": ["messageitem", "createdAt"], "timestamp": ["messageitem", "createdAt"],
},
"construct": {
"matrixuser": [
"@rmass_",
{"resolved": "sender"},
":loxthelion.com",
],
},
"transform": {
"matrixuser": {
"@rmass_238302:loxthelion.com": "@lyncoln:loxthelion.com",
},
},
} }
keys = [ keys = [
{ {
"keytitle": "msgtype", "keytitle": "msgtype",
@@ -30,6 +45,17 @@ keys = [
"resolved": "message_body", "resolved": "message_body",
}, },
}, },
{
"keytitle": "format",
"keyvalue": "org.matrix.custom.html",
},
{
"keytitle": "formatted_body",
"keyvalue": {
"resolved": "message_body",
},
},
] ]
method = "PUT" method = "PUT"
@@ -39,9 +65,9 @@ path = [
{"resolved": "room_id"}, {"resolved": "room_id"},
"/send/m.room.message/", "/send/m.room.message/",
{"resolved": "message_id"}, {"resolved": "message_id"},
"?user_id=@rmass_", "?user_id=",
{"resolved": "sender"}, {"resolved": "matrixuser"},
":loxthelion.com&ts=", "&ts=",
{"resolved": "timestamp"}, {"resolved": "timestamp"},
"000" "000"
] ]
+2
View File
@@ -7,8 +7,10 @@ kind = "action"
showstatus = True showstatus = True
resolve = { resolve = {
"get": {
"sender": ["messages", 0, "senderId"], "sender": ["messages", 0, "senderId"],
"username": ["profile", "username"], "username": ["profile", "username"],
}
} }
keys = [ keys = [
{ {
+1
View File
@@ -0,0 +1 @@
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