Skip to content
Snippets Groups Projects
Commit c427ebf8 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by gracedb-dev1
Browse files

adding safeguard which has all alerts (phone, email, XMPP) only turned on for production servers

parent a6435bcd
No related branches found
No related tags found
No related merge requests found
......@@ -147,7 +147,7 @@ def prepareSummary(event):
def issueAlertForUpdate(event, description, doxmpp, filename="", serialized_object=None):
if doxmpp:
issueXMPPAlert(event, filename, "update", description, serialized_object)
# XXX No emails for this. Argh.
# XXX No emails or phone calls for this. Argh.
# The only kind of serialized object relevant for a Label is an event.
def issueAlertForLabel(event, label, doxmpp, serialized_event=None, event_url=None):
......@@ -199,18 +199,24 @@ def issueAlertForLabel(event, label, doxmpp, serialized_event=None, event_url=No
toaddresses = []
bccaddresses = profileRecips
if toaddresses or bccaddresses:
if settings.SEND_EMAIL_ALERTS and (toaddresses or bccaddresses):
if not toaddresses:
toaddresses = ["(undisclosed recipients)"]
email = EmailMessage(subject, message, fromaddress, toaddresses, bccaddresses)
email.send()
# Make phone calls.
if phoneRecips:
if settings.SEND_PHONE_ALERTS and phoneRecips:
make_twilio_calls(event, phoneRecips, "label", label=label)
def issueEmailAlert(event, event_url):
# Check settings switch for turning off email alerts
if not settings.SEND_EMAIL_ALERTS:
log.debug(("Email alert for event {gid} not sent because email alerts "
"are turned off").format(gid=event.graceid()))
return
# The right way of doing this is to make the email alerts filter-able
# by search. But this is a low priority dev task. For now, we simply
# short-circuit in case this is an MDC event.
......@@ -264,13 +270,20 @@ Event Summary:
email.send()
def issuePhoneAlert(event):
# Check settings switch for turning off phone alerts
if not settings.SEND_PHONE_ALERTS:
log.debug(("Phone alert for event {gid} not sent because phone alerts "
"are turned off").format(gid=event.graceid()))
return
# The right way of doing this is to make the email alerts filter-able
# by search. But this is a low priority dev task. For now, we simply
# short-circuit in case this is an MDC event.
if event.search and event.search.name == 'MDC':
return
# Gather Recipients
# Gather recipients
phoneRecips = []
if event.group.name != 'Test':
pipeline = event.pipeline
......
......@@ -40,8 +40,10 @@ ALLOWED_HOSTS = ['localhost', '127.0.0.1', SERVER_FQDN,
'{0}.ligo.org'.format(socket.gethostname())]
# LVAlert and LVAlert Overseer settings ---------------------------------------
# Set to False to prevent XMPP alerts from being sent out.
SEND_XMPP_ALERTS = True
# Switches which control whether alerts are sent out
SEND_XMPP_ALERTS = False
SEND_PHONE_ALERTS = False
SEND_EMAIL_ALERTS = False
# Use LVAlert Overseer?
USE_LVALERT_OVERSEER = True
# LVAlert servers
......
......@@ -15,3 +15,8 @@ ALERT_XMPP_SERVERS = ["lvalert.cgca.uwm.edu"]
LVALERT_OVERSEER_PORTS = {
"lvalert.cgca.uwm.edu": 8000,
}
# Turn on alerts
SEND_XMPP_ALERTS = True
SEND_PHONE_ALERTS = True
SEND_EMAIL_ALERTS = True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment