Commit ebd789b8 authored by nimrod's avatar nimrod
Browse files

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.
parent 3536eee9
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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