From d1e85443753f868078c370d5942867a5d0cf558e Mon Sep 17 00:00:00 2001 From: Jeny Sadadia Date: Mon, 8 Jul 2024 16:18:57 +0530 Subject: [PATCH] Create notification for incidents Add subscription script for creating email notification when an incident is created or updated. It will send an email to associated issue submitter/subscriber. Signed-off-by: Jeny Sadadia --- .../subscriptions/incident_notification.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 kcidb/monitor/subscriptions/incident_notification.py diff --git a/kcidb/monitor/subscriptions/incident_notification.py b/kcidb/monitor/subscriptions/incident_notification.py new file mode 100644 index 00000000..fd8f632d --- /dev/null +++ b/kcidb/monitor/subscriptions/incident_notification.py @@ -0,0 +1,20 @@ +"""Incident notifications""" + +from kcidb.monitor.output import NotificationMessage as Message + + +def match_incident(incident): + """Send notification upon incident creation""" + + print(f"Generating notification for {incident.id}") + # if not incident.issue.subsriber: + # return () + + # static subscriber for testing + subscriber = "Jeny Sadadia " + + return (Message( + subject='Incident notification for {% include "incident_summary.txt.j2" %}', + to=[subscriber], + body='{% include "incident_description.txt.j2" %}', + ),)