From af5c2124503480417c2c498005bf9b8c0ca76764 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 9 Feb 2023 07:20:07 +0000 Subject: [PATCH] Ingest when there are no matches, add extra validation for send empty --- core/lib/rules.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/lib/rules.py b/core/lib/rules.py index 684d745..b4bfa59 100644 --- a/core/lib/rules.py +++ b/core/lib/rules.py @@ -347,6 +347,7 @@ class NotificationRuleData(object): self.store_match(index, message) self.ingest_matches_sync(index, message, meta, mode) + # No async helper for this one as we only need it for schedules async def rule_no_match(self, index=None): """ A rule has not matched. @@ -362,6 +363,9 @@ class NotificationRuleData(object): if self.object.send_empty: rule_notify(self.object, index, "no_match", None) self.store_match(index, False) + await self.ingest_matches( + index=index, message={}, meta={"msg": "No matches"}, mode="schedule" + ) async def run_schedule(self): """ @@ -468,6 +472,10 @@ class NotificationRuleData(object): raise RuleParseError( "Field tags cannot be used with on-demand rules", "data" ) + if self.cleaned_data["send_empty"]: + raise RuleParseError( + "Field cannot be used with on-demand rules", "send_empty" + ) @property def is_schedule(self):