Ingest when there are no matches, add extra validation for send empty

This commit is contained in:
Mark Veidemanis 2023-02-09 07:20:07 +00:00
parent 2a034a16e7
commit af5c212450
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 8 additions and 0 deletions

View File

@ -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):