applyConditions filter added and in working state. Needs to be made more generic by removing specific output target
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
|||||||
|
def applyConditions(definition, outputs):
|
||||||
|
if hasattr(definition, "filters"):
|
||||||
|
for filter in definition.filters:
|
||||||
|
print("DEBUG applyConditons filter item consumption")
|
||||||
|
print(outputs["event"])
|
||||||
|
|
||||||
|
item = outputs["event"]
|
||||||
|
|
||||||
|
#current_value = item[filter["filterkey"]]
|
||||||
|
|
||||||
|
if filter["operator"] == ">=":
|
||||||
|
if item[filter["filterkey"]] >= filter["filtervalue"]:
|
||||||
|
print("Applying filters")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if filter["operator"] == "==":
|
||||||
|
if item[filter["filterkey"]] == filter["filtervalue"]:
|
||||||
|
print("Applying filters")
|
||||||
|
return True
|
||||||
|
|
||||||
|
if filter["operator"] == "in":
|
||||||
|
if filter["filtervalue"] in outputs[filter["filterkey"]]:
|
||||||
|
print("Applying filters")
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
@@ -20,7 +20,7 @@ def buildOutput(response, action, outputs):
|
|||||||
for output_name, response_key in action.outputs.items():
|
for output_name, response_key in action.outputs.items():
|
||||||
if key == response_key:
|
if key == response_key:
|
||||||
outputs[output_name] = value
|
outputs[output_name] = value
|
||||||
|
#print (response_data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("No response received"),
|
print("No response received"),
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
from core.runtime.outputs import buildOutput
|
from core.runtime.outputs import buildOutput
|
||||||
|
from core.runtime.applyconditions import applyConditions
|
||||||
from core.execution.operation import buildOperation
|
from core.execution.operation import buildOperation
|
||||||
|
|
||||||
def buildListener(listener, self):
|
def buildListener(listener, self):
|
||||||
@@ -20,23 +21,31 @@ def buildListener(listener, self):
|
|||||||
#if applyConditions(listener, outputs)
|
#if applyConditions(listener, outputs)
|
||||||
# continue
|
# continue
|
||||||
|
|
||||||
print(outputs)
|
#print(outputs)
|
||||||
for event in outputs[listener.recursive["source"]]:
|
|
||||||
|
|
||||||
print("DEBUG")
|
|
||||||
print(listener.recursive["source"])
|
|
||||||
|
|
||||||
if "state_key" in event:
|
for item in outputs[listener.recursive["source"]]:
|
||||||
|
outputs[listener.recursive["label"]] = item
|
||||||
|
|
||||||
|
print("DEBUG item selection")
|
||||||
|
#print(listener.recursive["label"])
|
||||||
|
print(item)
|
||||||
|
print(outputs["event"])
|
||||||
|
|
||||||
|
if applyConditions(listener, outputs):
|
||||||
continue
|
continue
|
||||||
if event.get("sender") != "@lyncoln:loxthelion.com":
|
|
||||||
continue
|
#if "state_key" in event:
|
||||||
if "com.loxthelion.rmass_message_id" in event.get("content", {}):
|
#continue
|
||||||
continue
|
#if event.get("sender") != "@lyncoln:loxthelion.com":
|
||||||
if event.get("type") == "m.room.message":
|
#continue
|
||||||
|
#if "com.loxthelion.rmass_message_id" in event.get("content", {}):
|
||||||
|
#continue
|
||||||
|
#if event.get("type") == "m.room.message":
|
||||||
# Process and forward to RMASS
|
# Process and forward to RMASS
|
||||||
|
|
||||||
outputs = buildOperation(listener.execute, outputs)
|
#outputs = buildOperation(listener.execute, outputs)
|
||||||
|
#print(event)
|
||||||
|
|
||||||
self.send_response(200)
|
self.send_response(200)
|
||||||
self.send_header("Content-Type", "application/json")
|
self.send_header("Content-Type", "application/json")
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -15,7 +15,24 @@ execute = rmassmessagepush
|
|||||||
recursive = {
|
recursive = {
|
||||||
"source": "events",
|
"source": "events",
|
||||||
"reverse": False,
|
"reverse": False,
|
||||||
"label": "outboundmessage",
|
"label": "event",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filters = [
|
||||||
|
{
|
||||||
|
"filterkey": "event",
|
||||||
|
"operator": "in",
|
||||||
|
"filtervalue": "state_key",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filterkey": "sender",
|
||||||
|
"operator": "!=",
|
||||||
|
"filtervalue": "@lyncoln:loxthelion.com",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filterkey": "type",
|
||||||
|
"operator": "==",
|
||||||
|
"filtervalue": "m.room.message",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTIyMjI5MjQsIm5iZiI6MTc5MjIyMjc0NCwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjIyMjgwNH0.ZAGwq0DlacX_VBfysDOu6pAlt1FzwccZe1zIlMZcozOs_C7jOiOhkC-o1BH4-UPxe_MniYKux3s5br6kwJHFqQ", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQ4MTQ4MDQsIm5iZiI6MTc5MjIyMjc0NCwianRpIjoiRmVoVGM1cVFwQUQvRWtjYW1aLy85YllLbVB2ZEhPSXYyUE9YM25aTlhPRT0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MjIyMjgwNCwic3ViIjoiMjM4MzAyIn0.BOPpuwg88qWk5A0XciE2wi_4mC6V9jvnQzWms0vxIkWctsGMQ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