Core functionality for notifications. | (ns metabase.notification.core (:require [metabase.notification.payload.core :as notification.payload] [metabase.notification.seed :as notification.seed] [metabase.notification.send :as notification.send] [metabase.util :as u] [metabase.util.log :as log] [metabase.util.malli :as mu] [potemkin :as p])) |
------------------------------------------------------------------------------------------------;; Public APIs ;; ------------------------------------------------------------------------------------------------;; | |
(p/import-vars [notification.payload notification-payload] [notification.seed seed-notification!]) | |
(def ^:private Options [:map [:notification/sync? :boolean]]) | |
The default options for sending a notification. | (def ^:dynamic *default-options* {:notification/sync? false}) |
The function to send a notification. Defaults to | (mu/defn send-notification! [notification & {:keys [] :as options} :- [:maybe Options]] (let [options (merge *default-options* options) notification (with-meta notification {:notification/triggered-at-ns (u/start-timer)})] (log/debugf "Sending notification: %s %s" (:id notification) (if (:notification/sync? options) "synchronously" "asynchronously")) (if (:notification/sync? options) (notification.send/send-notification-sync! notification) (notification.send/send-notification-async! notification)))) |