diff --git a/core/execution/action/__pycache__/action.cpython-314.pyc b/core/execution/action/__pycache__/action.cpython-314.pyc index de70e62..de9cf09 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 e07e289..29bdf9e 100644 --- a/core/execution/action/action.py +++ b/core/execution/action/action.py @@ -7,11 +7,11 @@ def buildAction (action, outputs): if hasattr(action, "recursive"): items = outputs[action.recursive["source"]] - reverse = action.recursive.get("reversed", False) + reverse = action.recursive.get("reverse", False) if reverse: items = reversed(items) - + for item in items: outputs[action.recursive["label"]] = item outputs, resolved = buildPreRuntimeAttr(action, outputs) diff --git a/core/runtime/__pycache__/resolver.cpython-314.pyc b/core/runtime/__pycache__/resolver.cpython-314.pyc index 835627a..86fb6ef 100644 Binary files a/core/runtime/__pycache__/resolver.cpython-314.pyc and b/core/runtime/__pycache__/resolver.cpython-314.pyc differ diff --git a/core/runtime/resolver.py b/core/runtime/resolver.py index 9f23721..c4a56d8 100644 --- a/core/runtime/resolver.py +++ b/core/runtime/resolver.py @@ -1,11 +1,29 @@ def resolveItem(action, item): resolved = {} if hasattr(action, "resolve"): - for label, keys in action.resolve.items(): + for label, keys in action.resolve["get"].items(): target = item for key in keys: target = target[key] 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 diff --git a/core/server/__pycache__/server.cpython-314.pyc b/core/server/__pycache__/server.cpython-314.pyc index e4b4005..a96c06c 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 6bad3b3..a2f7e6e 100644 --- a/core/server/server.py +++ b/core/server/server.py @@ -8,7 +8,28 @@ from .createresponse import buildResponse 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(): + 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.bind(("0.0.0.0", port)) @@ -22,10 +43,6 @@ def startServer(): print("Accepting connections") connection.settimeout(30) - class RequestHandler(BaseHTTPRequestHandler): - def do_POST(self): - print("POST request received") - try: while True: data = connection.recv(4096) diff --git a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc index aa24498..48de30d 100644 Binary files a/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/getmessage.cpython-314.pyc differ diff --git a/plugins/rmass/actions/__pycache__/refresh_tokens.cpython-314.pyc b/plugins/rmass/actions/__pycache__/refresh_tokens.cpython-314.pyc index 0825c4e..97b9566 100644 Binary files a/plugins/rmass/actions/__pycache__/refresh_tokens.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/refresh_tokens.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 31cd838..d573812 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 97dcfa8..0f656df 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 8e3f619..9f71236 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 a6a7e33..1ebc72e 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 2cec932..e4b6990 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 0ab50f1..67d205f 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 a16098c..4d92fe6 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/__pycache__/synapseregister.cpython-314.pyc b/plugins/rmass/actions/__pycache__/synapseregister.cpython-314.pyc index 7696ee5..a07fcce 100644 Binary files a/plugins/rmass/actions/__pycache__/synapseregister.cpython-314.pyc and b/plugins/rmass/actions/__pycache__/synapseregister.cpython-314.pyc differ diff --git a/plugins/rmass/actions/getmessage.py b/plugins/rmass/actions/getmessage.py index 821855c..23dad36 100644 --- a/plugins/rmass/actions/getmessage.py +++ b/plugins/rmass/actions/getmessage.py @@ -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 resolve = { - "path": ["messageheaders", "id"], + "get": { + "path": ["messageheaders", "id"], + } } #To add resolution suffix, second item must be a dictionary. References the "path" library under resolved path = [ "https://rentmasseur.com/api/v1/mailbox/", {"resolved": "path"}, - #{ - # "output": "id", - # #"keys": [0, "id"] - # "keys": "id" - #} ] headers = { @@ -41,8 +38,8 @@ select = { "value": False, }, "exclude": { - "key": "senderId", - "value": 238302, + "key": {}, + "value": {}, } } diff --git a/plugins/rmass/actions/refresh_tokens.py b/plugins/rmass/actions/refresh_tokens.py index 8158305..7b4bddd 100644 --- a/plugins/rmass/actions/refresh_tokens.py +++ b/plugins/rmass/actions/refresh_tokens.py @@ -18,8 +18,6 @@ headers = { }, } -#domainname="rentmasseur.com" - cookies = { "accessToken": { "output": "access_token", diff --git a/plugins/rmass/actions/synapseassignspace.py b/plugins/rmass/actions/synapseassignspace.py index 8013476..20171a0 100644 --- a/plugins/rmass/actions/synapseassignspace.py +++ b/plugins/rmass/actions/synapseassignspace.py @@ -7,11 +7,14 @@ kind = "action" showstatus = True resolve = { - "sender": ["messages", 0, "senderId"], - "space_id": ["space_id"], - "username": ["profile", "username"], - "room_id": ["dmroom_id"], + "get": { + "sender": ["messages", 0, "senderId"], + "space_id": ["space_id"], + "username": ["profile", "username"], + "room_id": ["dmroom_id"], + }, } + keys = [ { "keytitle": "via", diff --git a/plugins/rmass/actions/synapseassignusername.py b/plugins/rmass/actions/synapseassignusername.py index 09871cc..166831e 100644 --- a/plugins/rmass/actions/synapseassignusername.py +++ b/plugins/rmass/actions/synapseassignusername.py @@ -9,9 +9,19 @@ showstatus = True astoken = os.environ["AS_TOKEN"] resolve = { - "sender": ["messages", 0, "senderId"], - "username": ["profile", "username"], + "get": { + "sender": ["messages", 0, "senderId"], + "username": ["profile", "username"], + }, + "construct": { + "matrixuser": [ + "@rmass_", + {"resolved": "sender"}, + ":loxthelion.com", + ], + }, } + keys = [ { "keytitle": "displayname", @@ -24,11 +34,10 @@ keys = [ method = "PUT" path = [ - "https://loxthelion.com/_matrix/client/v3/profile/@rmass_", - {"resolved": "sender"}, - ":loxthelion.com/displayname?user_id=@rmass_", - {"resolved": "sender"}, - ":loxthelion.com" + "https://loxthelion.com/_matrix/client/v3/profile/", + {"resolved": "matrixuser"}, + "/displayname?user_id=", + {"resolved": "matrixuser"}, ] headers = { diff --git a/plugins/rmass/actions/synapsecreatedmroom.py b/plugins/rmass/actions/synapsecreatedmroom.py index 8383983..ccb912a 100644 --- a/plugins/rmass/actions/synapsecreatedmroom.py +++ b/plugins/rmass/actions/synapsecreatedmroom.py @@ -7,8 +7,21 @@ kind = "action" showstatus = True resolve = { - "sender": ["messages", 0, "senderId"], - "username": ["profile", "username"], + "get": { + "sender": ["messages", 0, "senderId"], + "username": ["profile", "username"], + }, + "construct": { + "matrixuser": [ + "@rmass_", + {"resolved": "sender"}, + ":loxthelion.com", + ], + "matrixdm": [ + "rmass_dm_", + {"resolved": "sender"}, + ], + }, } keys = [ @@ -21,8 +34,7 @@ keys = [ { "keytitle": "room_alias_name", "keyvalue": { - "resolved": "sender", - "prefix": "rmass_dm_", + "resolved": "matrixdm", }, }, { @@ -55,9 +67,9 @@ keys = [ method = "POST" path = [ - "https://loxthelion.com/_matrix/client/v3/createRoom?user_id=@rmass_", - {"resolved": "sender"}, - ":loxthelion.com", + "https://loxthelion.com/_matrix/client/v3/createRoom?user_id=", + {"resolved": "matrixuser"}, + #":loxthelion.com", ] headers = { diff --git a/plugins/rmass/actions/synapsecreatespace.py b/plugins/rmass/actions/synapsecreatespace.py index a37aa4b..06cd1de 100644 --- a/plugins/rmass/actions/synapsecreatespace.py +++ b/plugins/rmass/actions/synapsecreatespace.py @@ -7,11 +7,19 @@ kind = "action" showstatus = True resolve = { - "sender": ["messages", 0, "senderId"], - #"messageid": ["message", "id"], - "username": ["profile", "username"], - "locationname": ["profile", "location"], - "locationcode": ["profile", "searchCity"], + "get": { + #"sender": ["messages", 0, "senderId"], + #"username": ["profile", "username"], + "locationname": ["profile", "location"], + "locationcode": ["profile", "searchCity"], + }, + "construct": { + "matrixspacealias": [ + "rmass_space_", + {"resolved": "locationcode"}, + #"%3Aloxthelion.com", + ], + }, } keys = [ { @@ -23,8 +31,8 @@ keys = [ { "keytitle": "room_alias_name", "keyvalue": { - "resolved": "locationcode", - "prefix": "rmass_space_", + "resolved": "matrixspacealias", + #"prefix": "rmass_space_", }, }, { @@ -46,7 +54,7 @@ keys = [ #"keyvalue": { #"users": { #"@lyncoln:loxthelion.com": 100, - #"@rmass_:loxthelion.com": 100, + #"@rmass_*:loxthelion.com": 100, #}, #}, #} @@ -55,9 +63,6 @@ keys = [ method = "POST" 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" ] diff --git a/plugins/rmass/actions/synapsegetroomid.py b/plugins/rmass/actions/synapsegetroomid.py index 49e0ada..7c31735 100644 --- a/plugins/rmass/actions/synapsegetroomid.py +++ b/plugins/rmass/actions/synapsegetroomid.py @@ -7,15 +7,23 @@ kind = "action" showstatus = True resolve = { - "sender": ["messages", 0, "senderId"], + "get": { + "sender": ["messages", 0, "senderId"], + }, + "construct": { + "matrixdm": [ + "%23rmass_dm_", + {"resolved": "sender"}, + "%3Aloxthelion.com", + ], + }, } method = "GET" path = [ - "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_dm_", - {"resolved": "sender"}, - "%3Aloxthelion.com", + "https://loxthelion.com/_matrix/client/v3/directory/room/", + {"resolved": "matrixdm"}, ] headers = { diff --git a/plugins/rmass/actions/synapsegetspaceid.py b/plugins/rmass/actions/synapsegetspaceid.py index e47dd63..fd86620 100644 --- a/plugins/rmass/actions/synapsegetspaceid.py +++ b/plugins/rmass/actions/synapsegetspaceid.py @@ -7,16 +7,23 @@ kind = "action" showstatus = True resolve = { - "sender": ["messages", 0, "senderId"], - "locationcode": ["profile", "searchCity"], + "get": { + "locationcode": ["profile", "searchCity"], + }, + "construct": { + "matrixspace": [ + "%23rmass_space_", + {"resolved": "locationcode"}, + "%3Aloxthelion.com", + ], + }, } method = "GET" path = [ - "https://loxthelion.com/_matrix/client/v3/directory/room/%23rmass_space_", - {"resolved": "locationcode"}, - "%3Aloxthelion.com", + "https://loxthelion.com/_matrix/client/v3/directory/room/", + {"resolved": "matrixspace"}, ] headers = { diff --git a/plugins/rmass/actions/synapsepushmessages.py b/plugins/rmass/actions/synapsepushmessages.py index 15679f1..d9041a9 100644 --- a/plugins/rmass/actions/synapsepushmessages.py +++ b/plugins/rmass/actions/synapsepushmessages.py @@ -13,12 +13,27 @@ recursive = { } resolve = { - "sender": ["messageitem", "senderId"], - "message_id": ["messageitem", "id"], - "message_body": ["messageitem", "text"], - "room_id": ["dmroom_id"], - "timestamp": ["messageitem", "createdAt"], + "get": { + "sender": ["messageitem", "senderId"], + "message_id": ["messageitem", "id"], + "message_body": ["messageitem", "text"], + "room_id": ["dmroom_id"], + "timestamp": ["messageitem", "createdAt"], + }, + "construct": { + "matrixuser": [ + "@rmass_", + {"resolved": "sender"}, + ":loxthelion.com", + ], + }, + "transform": { + "matrixuser": { + "@rmass_238302:loxthelion.com": "@lyncoln:loxthelion.com", + }, + }, } + keys = [ { "keytitle": "msgtype", @@ -30,6 +45,17 @@ keys = [ "resolved": "message_body", }, }, + { + "keytitle": "format", + "keyvalue": "org.matrix.custom.html", + }, + { + "keytitle": "formatted_body", + "keyvalue": { + "resolved": "message_body", + }, + }, + ] method = "PUT" @@ -39,9 +65,9 @@ path = [ {"resolved": "room_id"}, "/send/m.room.message/", {"resolved": "message_id"}, - "?user_id=@rmass_", - {"resolved": "sender"}, - ":loxthelion.com&ts=", + "?user_id=", + {"resolved": "matrixuser"}, + "&ts=", {"resolved": "timestamp"}, "000" ] diff --git a/plugins/rmass/actions/synapseregister.py b/plugins/rmass/actions/synapseregister.py index bb52524..da80e8f 100644 --- a/plugins/rmass/actions/synapseregister.py +++ b/plugins/rmass/actions/synapseregister.py @@ -7,8 +7,10 @@ kind = "action" showstatus = True resolve = { - "sender": ["messages", 0, "senderId"], - "username": ["profile", "username"], + "get": { + "sender": ["messages", 0, "senderId"], + "username": ["profile", "username"], + } } keys = [ { diff --git a/savedata/tokens.json b/savedata/tokens.json new file mode 100644 index 0000000..71096e7 --- /dev/null +++ b/savedata/tokens.json @@ -0,0 +1 @@ +{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwNDA4ODgsIm5iZiI6MTc5MjA0MDcwOCwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjA0MDc2OH0.8twTKQb2OG-OfT_C2eAwD2OpV__X7S-MWnpVXdLeLvBzfZcW6ZJLesvSqgYXeO56yn-_UblIUEwfy_B8EuDTSw", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ2MzI3NjgsIm5iZiI6MTc5MjA0MDcwOCwianRpIjoiUXRjRXE2TWtGdWhHNjdiTHdLak1kdzJXazIzMlFtVkp4K2J3aGs2RTlCZz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjA0MDc2OCwic3ViIjoiMjM4MzAyIn0.zmQ9S08NHgr2q0g3VloTgY3xBjATxXk2mdg6MbeHjuQ47OZ24E8bBNyRaqDJYJ0OnCkF5CvepJ5ISlnvkqTPRA"} \ No newline at end of file diff --git a/tokens.json b/tokens.json index 9f4e941..6ad53b0 100644 --- a/tokens.json +++ b/tokens.json @@ -1 +1 @@ -{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwMzI4ODYsIm5iZiI6MTc5MjAzMjcwNiwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAzMjc2Nn0.ChWvtapeudX4p0aEXxxMB0FWjDbLSCqgzevyi8UlhXj34l397o70_Owtns60TGh4JbC2l4EBInTggujF3bYREg", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ2MjQ3NjYsIm5iZiI6MTc5MjAzMjcwNiwianRpIjoibzNZYXMrNU5YNkRSc3pSa05kOTBQa3BMMTJ5VXkwWWx6ZTVNUUZMbFovcz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjAzMjc2Niwic3ViIjoiMjM4MzAyIn0.tXWt8Jgc9jW006ZKSPMsueWNUNWaaenlkDc9-TphAkLDtWWRY5_2zz8Bdt8qgl_s0NJ_WDXnv6WwU5on054BZA"} \ No newline at end of file +{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwODQ2MDksIm5iZiI6MTc5MjA4NDQyOSwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjA4NDQ4OX0.CcXQrFvFl5LraO3VWoe3CZ4u-jAHVuMt6Fag2_v5QJ79ekRsPMnOFSMjLycaZoc0hTZRiJnpUIqBWKmTsg2juA", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ2NzY0ODksIm5iZiI6MTc5MjA4NDQyOSwianRpIjoiQjIrSmxQWVdvYjYvOVBYTjZ3VnFrZzhmZHFrY05nQVZjbHF5YVluclJUdz0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjA4NDQ4OSwic3ViIjoiMjM4MzAyIn0.RSOQP-lQv7N7Ut_YOkwF58-k-kGoFYCsGqYISJiUxajJ2YuDWz6vMQoWCN82NYUPJvfFDnGgiiugAnrhWS-OoQ"} \ No newline at end of file