Deal only with the payload
This commit is contained in:
parent
3d6f69173b
commit
fa9553ec83
|
@ -21,16 +21,11 @@
|
||||||
|
|
||||||
(defn listen! [& {app :app mqtt-client :mqtt-client topic :topic logger :logger}]
|
(defn listen! [& {app :app mqtt-client :mqtt-client topic :topic logger :logger}]
|
||||||
(let [note-chan (mqtt/subscribe! mqtt-client topic)]
|
(let [note-chan (mqtt/subscribe! mqtt-client topic)]
|
||||||
(go-loop [note (<! note-chan)]
|
(go-loop [note-msg (<! note-chan)]
|
||||||
(if note
|
(if note-msg
|
||||||
(do (if (t/validate Notification note)
|
(let [note (-> note-msg :payload (update :urgency keyword))]
|
||||||
(notify/send-notification! mqtt-client
|
(if (t/validate Notification note)
|
||||||
{
|
(notify/send-notification! mqtt-client (assoc note :app app))
|
||||||
:app app
|
|
||||||
:summary (:summary note)
|
|
||||||
:body (:body note)
|
|
||||||
:urgency (-> note :urgency (keyword))
|
|
||||||
})
|
|
||||||
(let [err (humanize (t/explain Notification note))]
|
(let [err (humanize (t/explain Notification note))]
|
||||||
(log/error! logger (format "rejecting invalid notification: %s (%s)\n%s"
|
(log/error! logger (format "rejecting invalid notification: %s (%s)\n%s"
|
||||||
(:summary err) (:body err)
|
(:summary err) (:body err)
|
||||||
|
|
Loading…
Reference in New Issue