diff --git a/__pycache__/login.cpython-314.pyc b/__pycache__/login.cpython-314.pyc index 9218da8..eec4017 100644 Binary files a/__pycache__/login.cpython-314.pyc and b/__pycache__/login.cpython-314.pyc differ diff --git a/core/apirequest/__pycache__/headers.cpython-314.pyc b/core/apirequest/__pycache__/headers.cpython-314.pyc new file mode 100644 index 0000000..952e284 Binary files /dev/null and b/core/apirequest/__pycache__/headers.cpython-314.pyc differ diff --git a/core/apirequest/__pycache__/request.cpython-314.pyc b/core/apirequest/__pycache__/request.cpython-314.pyc index 70112e4..9fc83c6 100644 Binary files a/core/apirequest/__pycache__/request.cpython-314.pyc and b/core/apirequest/__pycache__/request.cpython-314.pyc differ diff --git a/core/apirequest/headers.py b/core/apirequest/headers.py new file mode 100644 index 0000000..020fb91 --- /dev/null +++ b/core/apirequest/headers.py @@ -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 diff --git a/core/apirequest/request.py b/core/apirequest/request.py index eaaa6e4..05f5a22 100644 --- a/core/apirequest/request.py +++ b/core/apirequest/request.py @@ -1,6 +1,7 @@ from .object import buildObject from .path import buildPath -import os +from .headers import buildHeaders +#import os def buildRequest(definition, outputs, resolved): path = buildPath(definition.path, outputs, resolved) @@ -14,22 +15,6 @@ def buildRequest(definition, outputs, resolved): request["object"] = buildObject(definition.keys, outputs, resolved) if hasattr(definition, "headers"): - 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[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 + request["headers"] = buildHeaders(definition, request, outputs, resolved) return request, outputs diff --git a/core/execution/action/__pycache__/action.cpython-314.pyc b/core/execution/action/__pycache__/action.cpython-314.pyc index bb2910e..de70e62 100644 Binary files a/core/execution/action/__pycache__/action.cpython-314.pyc and b/core/execution/action/__pycache__/action.cpython-314.pyc differ diff --git a/core/execution/action/action.py b/core/execution/action/action.py index 524f051..e07e289 100644 --- a/core/execution/action/action.py +++ b/core/execution/action/action.py @@ -6,7 +6,13 @@ def buildAction (action, outputs): #outputs, resolved = buildPreRuntimeAttr(action, outputs) 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, resolved = buildPreRuntimeAttr(action, outputs) response, outputs = executeRequest(action, outputs, resolved) diff --git a/core/runtime/recursiveactions.py b/core/runtime/recursiveactions.py new file mode 100644 index 0000000..a87560f --- /dev/null +++ b/core/runtime/recursiveactions.py @@ -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 + diff --git a/core/server/__pycache__/server.cpython-314.pyc b/core/server/__pycache__/server.cpython-314.pyc index 664b11c..e4b4005 100644 Binary files a/core/server/__pycache__/server.cpython-314.pyc and b/core/server/__pycache__/server.cpython-314.pyc differ diff --git a/core/server/server.py b/core/server/server.py index d7ce386..6bad3b3 100644 --- a/core/server/server.py +++ b/core/server/server.py @@ -2,7 +2,7 @@ import socket import json import os import logging - +from http.server import HTTPServer, BaseHTTPRequestHandler from .dispatcher import dispatchRequest from .createresponse import buildResponse @@ -14,29 +14,42 @@ def startServer(): server.bind(("0.0.0.0", port)) lifecycles = {} - + server.listen() - logging.info(f"Server listening on port {port}") + print(f"Server listening on port {port}") while True: connection, address = server.accept() - logging.info("Accepting connections") + print("Accepting connections") + connection.settimeout(30) - while True: - data = connection.recv(4096) + class RequestHandler(BaseHTTPRequestHandler): + def do_POST(self): + print("POST request received") + + try: + while True: + data = connection.recv(4096) + + if not data: + print("Client Disconnected") + break - request = json.loads(data) + request = json.loads(data) - # if not data: - # break + thread, lifecycles, module, mode = dispatchRequest(request, lifecycles) - thread, lifecycles, module, mode = dispatchRequest(request, lifecycles) + response = buildResponse(module, thread, mode) - response = buildResponse(module, thread, mode) + connection.sendall( + 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") - connection.sendall( - json.dumps(response).encode("utf-8"), - ) - - connection.close() + finally: + connection.close() # server.close() diff --git a/initialize.py b/initialize.py index 5336a91..6ffef0a 100644 --- a/initialize.py +++ b/initialize.py @@ -1,5 +1,5 @@ from core.server.server import startServer -import login +#import login #login startServer() diff --git a/plugins/rmass/__pycache__/__init__.cpython-314.pyc b/plugins/rmass/__pycache__/__init__.cpython-314.pyc index b90fab0..cbb73b4 100644 Binary files a/plugins/rmass/__pycache__/__init__.cpython-314.pyc and b/plugins/rmass/__pycache__/__init__.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/synapseassignspace.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapseassignspace.cpython-314.pyc index 32a7559..31cd838 100644 Binary files a/plugins/rmass/actions/__pycache__/synapseassignspace.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapseassignspace.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/synapseassignusername.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapseassignusername.cpython-314.pyc index 1ea7691..97dcfa8 100644 Binary files a/plugins/rmass/actions/__pycache__/synapseassignusername.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapseassignusername.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/synapsecreatedmroom.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapsecreatedmroom.cpython-314.pyc index 361085a..8e3f619 100644 Binary files a/plugins/rmass/actions/__pycache__/synapsecreatedmroom.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapsecreatedmroom.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/synapsecreatespace.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapsecreatespace.cpython-314.pyc index fb15541..a6a7e33 100644 Binary files a/plugins/rmass/actions/__pycache__/synapsecreatespace.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapsecreatespace.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/synapsegetroomid.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapsegetroomid.cpython-314.pyc index fb90a1b..2cec932 100644 Binary files a/plugins/rmass/actions/__pycache__/synapsegetroomid.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapsegetroomid.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/synapsegetspaceid.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapsegetspaceid.cpython-314.pyc index 8f3ebcc..0ab50f1 100644 Binary files a/plugins/rmass/actions/__pycache__/synapsegetspaceid.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapsegetspaceid.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/synapsepushmessages.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapsepushmessages.cpython-314.pyc index cca4eaf..a16098c 100644 Binary files a/plugins/rmass/actions/__pycache__/synapsepushmessages.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapsepushmessages.cpython-314.pyc differ diff --git a/plugins/rmass/actions/synapseassignspace.py b/plugins/rmass/actions/synapseassignspace.py index 91c582c..8013476 100644 --- a/plugins/rmass/actions/synapseassignspace.py +++ b/plugins/rmass/actions/synapseassignspace.py @@ -28,7 +28,7 @@ path = [ {"resolved": "space_id"}, "/state/m.space.child/", {"resolved": "room_id"}, - "?user_id=@rmass_bridge_test:loxthelion.com" + "?user_id=@rmass_bridge:loxthelion.com" ] headers = { diff --git a/plugins/rmass/actions/synapsecreatedmroom.py b/plugins/rmass/actions/synapsecreatedmroom.py index 8b8b17b..8383983 100644 --- a/plugins/rmass/actions/synapsecreatedmroom.py +++ b/plugins/rmass/actions/synapsecreatedmroom.py @@ -22,7 +22,7 @@ keys = [ "keytitle": "room_alias_name", "keyvalue": { "resolved": "sender", - "prefix": "rmass_dmtest_", + "prefix": "rmass_dm_", }, }, { diff --git a/plugins/rmass/actions/synapsecreatespace.py b/plugins/rmass/actions/synapsecreatespace.py index 35e848e..a37aa4b 100644 --- a/plugins/rmass/actions/synapsecreatespace.py +++ b/plugins/rmass/actions/synapsecreatespace.py @@ -24,7 +24,7 @@ keys = [ "keytitle": "room_alias_name", "keyvalue": { "resolved": "locationcode", - "prefix": "rmass_spacetest_", + "prefix": "rmass_space_", }, }, { @@ -58,7 +58,7 @@ 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_test:loxthelion.com" + "https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_bridge:loxthelion.com" ] headers = { diff --git a/plugins/rmass/actions/synapsegetroomid.py b/plugins/rmass/actions/synapsegetroomid.py index 265481c..49e0ada 100644 --- a/plugins/rmass/actions/synapsegetroomid.py +++ b/plugins/rmass/actions/synapsegetroomid.py @@ -13,7 +13,7 @@ resolve = { method = "GET" path = [ - "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_dmtest_", + "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_dm_", {"resolved": "sender"}, "%3Aloxthelion.com", ] diff --git a/plugins/rmass/actions/synapsegetspaceid.py b/plugins/rmass/actions/synapsegetspaceid.py index 705d033..e47dd63 100644 --- a/plugins/rmass/actions/synapsegetspaceid.py +++ b/plugins/rmass/actions/synapsegetspaceid.py @@ -14,7 +14,7 @@ resolve = { method = "GET" path = [ - "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_spacetest_", + "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_space_", {"resolved": "locationcode"}, "%3Aloxthelion.com", ] diff --git a/plugins/rmass/actions/synapsepushmessages.py b/plugins/rmass/actions/synapsepushmessages.py index 9a94b14..15679f1 100644 --- a/plugins/rmass/actions/synapsepushmessages.py +++ b/plugins/rmass/actions/synapsepushmessages.py @@ -8,6 +8,7 @@ showstatus = True recursive = { "source": "messages", + "reverse": True, "label": "messageitem", } diff --git a/plugins/rmass/operations/__init__.py b/plugins/rmass/operations/__init__.py index 0366f92..83356a4 100644 --- a/plugins/rmass/operations/__init__.py +++ b/plugins/rmass/operations/__init__.py @@ -1,2 +1,2 @@ -from . import login, checkavailable, setavailable, pullmessagelist +from . import login, checkavailable, setavailable, synapsemessagepush diff --git a/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc b/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc index 20211af..0fda811 100644 Binary files a/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc and b/plugins/rmass/operations/__pycache__/__init__.cpython-314.pyc differ diff --git a/plugins/rmass/operations/__pycache__/synapsemessagepush.cpython-314.pyc b/plugins/rmass/operations/__pycache__/synapsemessagepush.cpython-314.pyc new file mode 100644 index 0000000..2f51a56 Binary files /dev/null and b/plugins/rmass/operations/__pycache__/synapsemessagepush.cpython-314.pyc differ diff --git a/plugins/rmass/operations/pullmessagelist.py b/plugins/rmass/operations/synapsemessagepush.py similarity index 100% rename from plugins/rmass/operations/pullmessagelist.py rename to plugins/rmass/operations/synapsemessagepush.py diff --git a/pullmessagelist.py b/synapsemessagepush.py similarity index 56% rename from pullmessagelist.py rename to synapsemessagepush.py index f4775ff..7849309 100644 --- a/pullmessagelist.py +++ b/synapsemessagepush.py @@ -3,5 +3,5 @@ from core.execution.operation import buildOperation -outputs = buildOperation(rmass.operations.pullmessagelist) +outputs = buildOperation(rmass.operations.synapsemessagepush) diff --git a/testrooms.json b/testrooms.json new file mode 100644 index 0000000..18c4deb --- /dev/null +++ b/testrooms.json @@ -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" +] diff --git a/tokens.json b/tokens.json index 93acca1..9f4e941 100644 --- a/tokens.json +++ b/tokens.json @@ -1 +1 @@ -{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwMTYxNzYsIm5iZiI6MTc5MjAxNTk5Niwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAxNjA1Nn0.x80ROCVbjmvc7D4FCbcFB7fWdvLL7Wm3TmBS8XN-lL-UyYGT1zGbmr_kDLpJ06I9-RtcKvkrX52cQKDHqfFplg", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ2MDgwNTYsIm5iZiI6MTc5MjAxNTk5NiwianRpIjoiLy9xblJvU3Voc3F2ZVRXUENURkRoRlVjRjhCTCsvV2hYZzJLVFErblN0az0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAxNjA1Niwic3ViIjoiMjM4MzAyIn0.4nTN0v_hXVE2XwCIS5ZH6zGp1TE3F9aQbOEasiSFu-Nvc_1fT4MsrXL9nr1FGgo_5N6uSfbgYAOioa7fyzucJA"} \ No newline at end of file +{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwMzI4ODYsIm5iZiI6MTc5MjAzMjcwNiwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAzMjc2Nn0.ChWvtapeudX4p0aEXxxMB0FWjDbLSCqgzevyi8UlhXj34l397o70_Owtns60TGh4JbC2l4EBInTggujF3bYREg", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ2MjQ3NjYsIm5iZiI6MTc5MjAzMjcwNiwianRpIjoibzNZYXMrNU5YNkRSc3pSa05kOTBQa3BMMTJ5VXkwWWx6ZTVNUUZMbFovcz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAzMjc2Niwic3ViIjoiMjM4MzAyIn0.tXWt8Jgc9jW006ZKSPMsueWNUNWaaenlkDc9-TphAkLDtWWRY5_2zz8Bdt8qgl_s0NJ_WDXnv6WwU5on054BZA"} \ No newline at end of file