From 14b5727923ca168bff3b69644861a4b113a5c383 Mon Sep 17 00:00:00 2001 From: Lyncoln Date: Wed, 28 Oct 2026 20:57:45 -0400 Subject: [PATCH] Added synapse notify to preexeccution filtering at the action level. Expanded filter metadata --- core/execution/action/action.py | 9 ++++++--- core/runtime/applyconditions.py | 7 ++++++- plugins/rmass/actions/rmassmessagepush.py | 9 +++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/execution/action/action.py b/core/execution/action/action.py index 7f2df24..136bcd9 100644 --- a/core/execution/action/action.py +++ b/core/execution/action/action.py @@ -12,10 +12,13 @@ def buildAction (action, outputs, process): if hasattr(action, "allowaction"): if not action.allowaction: - return outputs, None + return None if match: - return outputs, None + if filter.get("execute", False): + response, outputs = executeRequest(filter["execute"], outputs, resolved) + + return None response, outputs = executeRequest(action, outputs, resolved) @@ -27,4 +30,4 @@ def buildAction (action, outputs, process): if action_log: logging.info(f"{action.name} completed") - return outputs, response + return response diff --git a/core/runtime/applyconditions.py b/core/runtime/applyconditions.py index 6156a90..fc9ede1 100644 --- a/core/runtime/applyconditions.py +++ b/core/runtime/applyconditions.py @@ -17,7 +17,12 @@ def applyConditions(definition, dictionary, outputs): if filtervalue is None: continue - resolvedvalue = dictionary.get(filter["filterkey"]) + if filter.get("filterkey_format", None): + if filter["filterkey_format"] == "length": + resolvedvalue = len(dictionary.get(filter["filterkey"])) + + else: + resolvedvalue = dictionary.get(filter["filterkey"]) if filter["operator"] == ">=": if int(resolvedvalue or 0) >= int(filtervalue): diff --git a/plugins/rmass/actions/rmassmessagepush.py b/plugins/rmass/actions/rmassmessagepush.py index c5baddf..ec1a955 100644 --- a/plugins/rmass/actions/rmassmessagepush.py +++ b/plugins/rmass/actions/rmassmessagepush.py @@ -88,6 +88,15 @@ outputs = { ##Filter test against recursiveset filters = [ + { + "filterkey": "message_body", + #"filterkey_lib": "outputs", + "filterkey_format": "length", + "execute": synapsenotify, + "operator": "<", + "filtervalue": 5, + "print": f"Message body is less than 5 characters. Notifying with {synapsenotify.name}...", + }, { "filterkey": "msgtype", "operator": "==",