Refined header code, added reverse recursive action
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
@@ -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)
|
||||
|
||||
@@ -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.
+27
-14
@@ -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
|
||||
|
||||
@@ -16,27 +16,40 @@ def startServer():
|
||||
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")
|
||||
|
||||
request = json.loads(data)
|
||||
try:
|
||||
while True:
|
||||
data = connection.recv(4096)
|
||||
|
||||
# if not data:
|
||||
# break
|
||||
if not data:
|
||||
print("Client Disconnected")
|
||||
break
|
||||
|
||||
thread, lifecycles, module, mode = dispatchRequest(request, lifecycles)
|
||||
request = json.loads(data)
|
||||
|
||||
response = buildResponse(module, thread, mode)
|
||||
thread, lifecycles, module, mode = dispatchRequest(request, lifecycles)
|
||||
|
||||
connection.sendall(
|
||||
json.dumps(response).encode("utf-8"),
|
||||
)
|
||||
response = buildResponse(module, thread, mode)
|
||||
|
||||
connection.close()
|
||||
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")
|
||||
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
# server.close()
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
from core.server.server import startServer
|
||||
import login
|
||||
#import login
|
||||
|
||||
#login
|
||||
startServer()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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 = {
|
||||
|
||||
@@ -22,7 +22,7 @@ keys = [
|
||||
"keytitle": "room_alias_name",
|
||||
"keyvalue": {
|
||||
"resolved": "sender",
|
||||
"prefix": "rmass_dmtest_",
|
||||
"prefix": "rmass_dm_",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
|
||||
@@ -8,6 +8,7 @@ showstatus = True
|
||||
|
||||
recursive = {
|
||||
"source": "messages",
|
||||
"reverse": True,
|
||||
"label": "messageitem",
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
from . import login, checkavailable, setavailable, pullmessagelist
|
||||
from . import login, checkavailable, setavailable, synapsemessagepush
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -3,5 +3,5 @@ from core.execution.operation import buildOperation
|
||||
|
||||
|
||||
|
||||
outputs = buildOperation(rmass.operations.pullmessagelist)
|
||||
outputs = buildOperation(rmass.operations.synapsemessagepush)
|
||||
|
||||
@@ -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
@@ -1 +1 @@
|
||||
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIwMTYxNzYsIm5iZiI6MTc5MjAxNTk5Niwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR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