From 142ae322560facd659c2f0d7b00e8d43260ff009 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 22 Jul 2024 13:08:46 +0200 Subject: [PATCH] :sparkles: Add better call signature for srepl/notify! fn helper --- backend/src/app/srepl/main.clj | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index 1c4c5430a..0a5181ffe 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -190,6 +190,12 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defn notify! + "Send flash notifications. + + This method allows send flash notifications to specified target destinations. + The message can be a free text or a preconfigured one. + + The destination can be: all, profile-id, team-id, or a coll of them." [{:keys [::mbus/msgbus ::db/pool]} & {:keys [dest code message level] :or {code :generic level :info} :as params}] @@ -197,10 +203,6 @@ ["invalid level %" level] (contains? #{:success :error :info :warning} level)) - (dm/verify! - ["invalid code: %" code] - (contains? #{:generic :upgrade-version} code)) - (letfn [(send [dest] (l/inf :hint "sending notification" :dest (str dest)) (let [message {:type :notification @@ -226,6 +228,9 @@ (resolve-dest [dest] (cond + (= :all dest) + [uuid/zero] + (uuid? dest) [dest] @@ -241,14 +246,15 @@ (mapcat resolve-dest)) dest) - (and (coll? dest) - (every? coll? dest)) + (and (vector? dest) + (every? vector? dest)) (sequence (comp (map vec) (mapcat resolve-dest)) dest) - (vector? dest) + (and (vector? dest) + (keyword? (first dest))) (let [[op param] dest] (cond (= op :email)