From 56d52a5beb3dd94bb305c004a781315710e70fdd Mon Sep 17 00:00:00 2001 From: niten Date: Thu, 18 May 2023 14:06:00 -0700 Subject: [PATCH] Pass expected urgency format --- src/tattler/core.clj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tattler/core.clj b/src/tattler/core.clj index d45dc45..517b6b7 100644 --- a/src/tattler/core.clj +++ b/src/tattler/core.clj @@ -19,6 +19,11 @@ [:body (sized-string 1 256)] [:urgency [:and :int [:>= 0] [:<= 10]]]])) +(defn- codify-urgency [urgency] + (cond (<= 0 urgency 3) :low + (<= 4 urgency 7) :normal + (<= 8 urgency 10) :critical)) + (defn listen! [& {app :app mqtt-client :mqtt-client topic :topic logger @@ -30,7 +35,10 @@ (let [note (:payload note-msg)] (if (t/validate Notification note) (when (>= (:urgency note) urgency-threshold) - (notify/send-notification! mqtt-client (assoc note :app app)) + (notify/send-notification! mqtt-client + (-> note + (assoc :app app) + (update :urgency codify-urgency))) (log/info! logger (format "ignoring low-urgency message (%s): %s" (:urgency note) (:summary note))))