From ebd789b825fb5566afaaeb0c7069de8973c2de0e Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Wed, 23 Feb 2022 20:18:05 +0200
Subject: [PATCH] Don't send empty notifications.

If the message is an empty string or in the fallback case of using the
request data if the message is None, don't send a notification.
---
 app.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app.py b/app.py
index 135c71a..a29922a 100644
--- a/app.py
+++ b/app.py
@@ -22,7 +22,7 @@ def ping():
 
 
 @app.route("/send", methods=["GET", "POST"])
-def send_message():
+def send_message():  # noqa: MC0001
     """Send a notification."""
     if request.method == "POST":
         # Needs to be called before accessing other request parameters,
@@ -39,6 +39,9 @@ def send_message():
     else:
         message = request.args["message"]
 
+    if message is None or message.strip() == "":
+        raise RuntimeError("No message or message is empty.")
+
     for c in client.containers.list():  # pylint: disable=invalid-name
         if c.name == CONTAINER_NAME:
             container = c
-- 
GitLab