From 5301971845658d8c450c8c728ad762c600dce8c8 Mon Sep 17 00:00:00 2001
From: Alexander Pace <alexander.pace@ligo.org>
Date: Thu, 15 Feb 2024 16:38:11 +0000
Subject: [PATCH] optionally turn off igwn-alerts to *_{search} topics

---
 config/settings/base.py | 7 +++++++
 gracedb/alerts/xmpp.py  | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/config/settings/base.py b/config/settings/base.py
index f967b640a..223b58a25 100644
--- a/config/settings/base.py
+++ b/config/settings/base.py
@@ -150,6 +150,13 @@ SEND_MATTERMOST_ALERTS = False
 # IGWN_ALERT_GROUP environment variable. 
 DEFAULT_IGWN_ALERT_GROUP = 'lvalert-dev'
 
+# enable/disable sending alerts to topics that have the search tag
+# for g/e-events. default to false, so only send to {group}_{pipeline}
+SEND_TO_SEARCH_TOPICS = parse_envvar_bool(
+    get_from_env('IGWN_ALERT_SEARCH_TOPICS',
+                 fail_if_not_found=False, default_value="false")
+)
+
 # overseer timeout:
 OVERSEER_TIMEOUT = float(get_from_env('IGWN_ALERT_OVERSEER_TIMEOUT',
     fail_if_not_found=False, default_value=0.1))
diff --git a/gracedb/alerts/xmpp.py b/gracedb/alerts/xmpp.py
index 83cec7f58..21cc9d6b6 100644
--- a/gracedb/alerts/xmpp.py
+++ b/gracedb/alerts/xmpp.py
@@ -48,7 +48,7 @@ def get_xmpp_node_names(event_or_superevent):
         gp_node = "{group}_{pipeline}".format(group=event.group.name,
             pipeline=event.pipeline.name).lower()
         node_names.append(gp_node)
-        if event.search:
+        if event.search and settings.SEND_TO_SEARCH_TOPICS:
             gps_node = gp_node + "_{search}".format(
                 search=event.search.name.lower())
             node_names.append(gps_node)
-- 
GitLab