Refined header code, added reverse recursive action

This commit is contained in:
Lyncoln
2026-10-14 23:06:50 -04:00
parent 3acd3fafc5
commit 61ee8145ae
32 changed files with 118 additions and 45 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
+21
View File
@@ -0,0 +1,21 @@
import os
def buildHeaders(definition, request, outputs, resolved):
headers = {}
for header_name, header_value in definition.headers.items():
value = header_value
if isinstance(value, dict) and "output" in header_value:
value = outputs[value["output"]]
if isinstance(value, dict) and "os" in header_value:
value = os.environ.get(value["os"])
if isinstance(header_value, dict) and "prefix" in header_value:
value = header_value["prefix"] + value
headers[header_name] = value
request["headers"] = headers
return headers
+3 -18
View File
@@ -1,6 +1,7 @@
from .object import buildObject from .object import buildObject
from .path import buildPath from .path import buildPath
import os from .headers import buildHeaders
#import os
def buildRequest(definition, outputs, resolved): def buildRequest(definition, outputs, resolved):
path = buildPath(definition.path, outputs, resolved) path = buildPath(definition.path, outputs, resolved)
@@ -14,22 +15,6 @@ def buildRequest(definition, outputs, resolved):
request["object"] = buildObject(definition.keys, outputs, resolved) request["object"] = buildObject(definition.keys, outputs, resolved)
if hasattr(definition, "headers"): if hasattr(definition, "headers"):
headers = {} request["headers"] = buildHeaders(definition, request, outputs, resolved)
for header_name, header_value in definition.headers.items():
value = header_value
if isinstance(value, dict) and "output" in header_value:
value = outputs[value["output"]]
if isinstance(value, dict) and "os" in header_value:
#value = os.environ[definition.headers[header_name]["os"]]
value = os.environ["AS_TOKEN"]
if isinstance(header_value, dict) and "prefix" in header_value:
value = header_value["prefix"] + value
headers[header_name] = value
request["headers"] = headers
return request, outputs return request, outputs
+7 -1
View File
@@ -6,7 +6,13 @@ def buildAction (action, outputs):
#outputs, resolved = buildPreRuntimeAttr(action, outputs) #outputs, resolved = buildPreRuntimeAttr(action, outputs)
if hasattr(action, "recursive"): if hasattr(action, "recursive"):
for item in outputs[action.recursive["source"]]: items = outputs[action.recursive["source"]]
reverse = action.recursive.get("reversed", False)
if reverse:
items = reversed(items)
for item in items:
outputs[action.recursive["label"]] = item outputs[action.recursive["label"]] = item
outputs, resolved = buildPreRuntimeAttr(action, outputs) outputs, resolved = buildPreRuntimeAttr(action, outputs)
response, outputs = executeRequest(action, outputs, resolved) response, outputs = executeRequest(action, outputs, resolved)
+17
View File
@@ -0,0 +1,17 @@
from core.execution.action.action import buildAction
def recursiveSet(definition, outputs):
recursiveset = definition.recursiveset["actions"]
for item in outputs[definition.recursiveset["source"]]:
outputs[definition.recursiveset["outputlabel"]] = item
#outputs["recursive"] = item
for job in recursiveset:
outputs, response = buildAction(job, outputs)
print(outputs["profile"])
print(outputs["messages"])
return outputs
from core.execution.action.action import buildAction
Binary file not shown.
+19 -6
View File
@@ -2,7 +2,7 @@ import socket
import json import json
import os import os
import logging import logging
from http.server import HTTPServer, BaseHTTPRequestHandler
from .dispatcher import dispatchRequest from .dispatcher import dispatchRequest
from .createresponse import buildResponse from .createresponse import buildResponse
@@ -16,18 +16,25 @@ def startServer():
lifecycles = {} lifecycles = {}
server.listen() server.listen()
logging.info(f"Server listening on port {port}") print(f"Server listening on port {port}")
while True: while True:
connection, address = server.accept() connection, address = server.accept()
logging.info("Accepting connections") print("Accepting connections")
connection.settimeout(30)
class RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
print("POST request received")
try:
while True: while True:
data = connection.recv(4096) data = connection.recv(4096)
request = json.loads(data) if not data:
print("Client Disconnected")
break
# if not data: request = json.loads(data)
# break
thread, lifecycles, module, mode = dispatchRequest(request, lifecycles) thread, lifecycles, module, mode = dispatchRequest(request, lifecycles)
@@ -36,7 +43,13 @@ def startServer():
connection.sendall( connection.sendall(
json.dumps(response).encode("utf-8"), json.dumps(response).encode("utf-8"),
) )
except json.decoder.JSONDecodeError as error:
print("Invalid JSON received", error)
print("Closing client connection")
except socket.timeout:
print("Client connection timed out")
finally:
connection.close() connection.close()
# server.close() # server.close()
+1 -1
View File
@@ -1,5 +1,5 @@
from core.server.server import startServer from core.server.server import startServer
import login #import login
#login #login
startServer() startServer()
Binary file not shown.
+1 -1
View File
@@ -28,7 +28,7 @@ path = [
{"resolved": "space_id"}, {"resolved": "space_id"},
"/state/m.space.child/", "/state/m.space.child/",
{"resolved": "room_id"}, {"resolved": "room_id"},
"?user_id=@rmass_bridge_test:loxthelion.com" "?user_id=@rmass_bridge:loxthelion.com"
] ]
headers = { headers = {
+1 -1
View File
@@ -22,7 +22,7 @@ keys = [
"keytitle": "room_alias_name", "keytitle": "room_alias_name",
"keyvalue": { "keyvalue": {
"resolved": "sender", "resolved": "sender",
"prefix": "rmass_dmtest_", "prefix": "rmass_dm_",
}, },
}, },
{ {
+2 -2
View File
@@ -24,7 +24,7 @@ keys = [
"keytitle": "room_alias_name", "keytitle": "room_alias_name",
"keyvalue": { "keyvalue": {
"resolved": "locationcode", "resolved": "locationcode",
"prefix": "rmass_spacetest_", "prefix": "rmass_space_",
}, },
}, },
{ {
@@ -58,7 +58,7 @@ path = [
#"https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_", #"https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_",
#{"resolved": "sender"}, #{"resolved": "sender"},
#":loxthelion.com", #":loxthelion.com",
"https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_bridge_test:loxthelion.com" "https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_bridge:loxthelion.com"
] ]
headers = { headers = {
+1 -1
View File
@@ -13,7 +13,7 @@ resolve = {
method = "GET" method = "GET"
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_dmtest_", "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_dm_",
{"resolved": "sender"}, {"resolved": "sender"},
"%3Aloxthelion.com", "%3Aloxthelion.com",
] ]
+1 -1
View File
@@ -14,7 +14,7 @@ resolve = {
method = "GET" method = "GET"
path = [ path = [
"https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_spacetest_", "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_space_",
{"resolved": "locationcode"}, {"resolved": "locationcode"},
"%3Aloxthelion.com", "%3Aloxthelion.com",
] ]
@@ -8,6 +8,7 @@ showstatus = True
recursive = { recursive = {
"source": "messages", "source": "messages",
"reverse": True,
"label": "messageitem", "label": "messageitem",
} }
+1 -1
View File
@@ -1,2 +1,2 @@
from . import login, checkavailable, setavailable, pullmessagelist from . import login, checkavailable, setavailable, synapsemessagepush
+1 -1
View File
@@ -3,5 +3,5 @@ from core.execution.operation import buildOperation
outputs = buildOperation(rmass.operations.pullmessagelist) outputs = buildOperation(rmass.operations.synapsemessagepush)
+30
View File
@@ -0,0 +1,30 @@
[
"!GmcMNwFtjQUVLZsINr:loxthelion.com",
"!GseJOgedWIEZJIFBof:loxthelion.com",
"!MedbFMjfngnXiOCvBl:loxthelion.com",
"!OxUixFApFPCCQqmYlP:loxthelion.com",
"!PpAcegYZCeaCsTWmAD:loxthelion.com",
"!QzNDQOxuxLpZdfoMSa:loxthelion.com",
"!SayRxBpXfrMEliTZWu:loxthelion.com",
"!TMbTcUkRbqymtlIqae:loxthelion.com",
"!XdrVLrVDPilgcwBrii:loxthelion.com",
"!ZIzEHnfXDQMrKDvbsf:loxthelion.com",
"!ZlnjVMBsBIzTooxUzx:loxthelion.com",
"!ZqZXiCjJSxoNKbuYIK:loxthelion.com",
"!agmQlrIIzRhCmrLlKz:loxthelion.com",
"!bnOsYLzfYwCiOUNtMc:loxthelion.com",
"!eImaLbIbsJCdFQCDwW:loxthelion.com",
"!gVaGhwJIHMPYpBCnaa:loxthelion.com",
"!giaDjvrUjCSAxZByFv:loxthelion.com",
"!gzBIZtRPqrqrXhhKfi:loxthelion.com",
"!iNeouCdsHqUzrOOoVF:loxthelion.com",
"!joaKUuLwoKDGBzyJvR:loxthelion.com",
"!mmIXIlbfbQvlJGcOrl:loxthelion.com",
"!oOKonquvcMNGGggsZj:loxthelion.com",
"!uKNmAyAXuqbJHPNdCJ:loxthelion.com",
"!uoJdCOQaCdrVtkzhDs:loxthelion.com",
"!wUyFfHUHKfLMrJlkrz:loxthelion.com",
"!xkeHqlqEIfFQZfDzoe:loxthelion.com",
"!yoOHZCCbENBeWJEwgx:loxthelion.com",
"!zihaZFtKrzvvxHvVha:loxthelion.com"
]
+1 -1
View File
@@ -1 +1 @@
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwMTYxNzYsIm5iZiI6MTc5MjAxNTk5Niwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAxNjA1Nn0.x80ROCVbjmvc7D4FCbcFB7fWdvLL7Wm3TmBS8XN-lL-UyYGT1zGbmr_kDLpJ06I9-RtcKvkrX52cQKDHqfFplg", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ2MDgwNTYsIm5iZiI6MTc5MjAxNTk5NiwianRpIjoiLy9xblJvU3Voc3F2ZVRXUENURkRoRlVjRjhCTCsvV2hYZzJLVFErblN0az0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAxNjA1Niwic3ViIjoiMjM4MzAyIn0.4nTN0v_hXVE2XwCIS5ZH6zGp1TE3F9aQbOEasiSFu-Nvc_1fT4MsrXL9nr1FGgo_5N6uSfbgYAOioa7fyzucJA"} {"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE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