mirror of
https://github.com/penpot/penpot.git
synced 2025-03-16 01:31:22 -05:00
🐛 Fix email sending.
This commit is contained in:
parent
460019e01b
commit
b4790c89ce
4 changed files with 26 additions and 14 deletions
|
@ -47,6 +47,7 @@
|
||||||
(s/def ::email-reply-to ::us/email)
|
(s/def ::email-reply-to ::us/email)
|
||||||
(s/def ::email-from ::us/email)
|
(s/def ::email-from ::us/email)
|
||||||
(s/def ::smtp-host ::us/string)
|
(s/def ::smtp-host ::us/string)
|
||||||
|
(s/def ::smtp-port ::us/integer)
|
||||||
(s/def ::smtp-user (s/nilable ::us/string))
|
(s/def ::smtp-user (s/nilable ::us/string))
|
||||||
(s/def ::smtp-password (s/nilable ::us/string))
|
(s/def ::smtp-password (s/nilable ::us/string))
|
||||||
(s/def ::smtp-tls ::us/boolean)
|
(s/def ::smtp-tls ::us/boolean)
|
||||||
|
@ -70,6 +71,7 @@
|
||||||
::email-reply-to
|
::email-reply-to
|
||||||
::email-from
|
::email-from
|
||||||
::smtp-host
|
::smtp-host
|
||||||
|
::smtp-port
|
||||||
::smtp-user
|
::smtp-user
|
||||||
::smtp-password
|
::smtp-password
|
||||||
::smtp-tls
|
::smtp-tls
|
||||||
|
|
|
@ -254,7 +254,7 @@
|
||||||
(let [data {:to (:email params)
|
(let [data {:to (:email params)
|
||||||
:name (:fullname params)}]
|
:name (:fullname params)}]
|
||||||
(p/do!
|
(p/do!
|
||||||
(emails/send! emails/register data)
|
(emails/send! conn emails/register data)
|
||||||
profile))))))
|
profile))))))
|
||||||
|
|
||||||
;; --- Mutation: Request Profile Recovery
|
;; --- Mutation: Request Profile Recovery
|
||||||
|
|
|
@ -102,6 +102,13 @@
|
||||||
(cond-> row
|
(cond-> row
|
||||||
props (assoc :props (blob/decode props)))))
|
props (assoc :props (blob/decode props)))))
|
||||||
|
|
||||||
|
(defn- log-error
|
||||||
|
[item err]
|
||||||
|
(log/error "Unhandled exception on task '" (:name item)
|
||||||
|
"' (retry:" (:retry-num item) ") \n"
|
||||||
|
(with-out-str
|
||||||
|
(.printStackTrace ^Throwable err (java.io.PrintWriter. *out*)))))
|
||||||
|
|
||||||
(defn- event-loop
|
(defn- event-loop
|
||||||
[{:keys [tasks] :as options}]
|
[{:keys [tasks] :as options}]
|
||||||
(let [queue (:queue options "default")
|
(let [queue (:queue options "default")
|
||||||
|
@ -114,9 +121,11 @@
|
||||||
(-> (p/do! (handle-task tasks item))
|
(-> (p/do! (handle-task tasks item))
|
||||||
(p/handle (fn [v e]
|
(p/handle (fn [v e]
|
||||||
(if e
|
(if e
|
||||||
(if (>= (:retry-num item) max-retries)
|
(do
|
||||||
(mark-as-failed conn item e)
|
(log-error item e)
|
||||||
(reschedule conn item e))
|
(if (>= (:retry-num item) max-retries)
|
||||||
|
(mark-as-failed conn item e)
|
||||||
|
(reschedule conn item e)))
|
||||||
(mark-as-completed conn item))))
|
(mark-as-completed conn item))))
|
||||||
(p/then' (constantly ::handled))))))))))
|
(p/then' (constantly ::handled))))))))))
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[postal.core :as postal]
|
[postal.core :as postal]
|
||||||
|
[vertx.core :as vc]
|
||||||
[promesa.core :as p]
|
[promesa.core :as p]
|
||||||
[uxbox.common.exceptions :as ex]
|
[uxbox.common.exceptions :as ex]
|
||||||
[uxbox.config :as cfg]
|
[uxbox.config :as cfg]
|
||||||
|
@ -48,16 +49,16 @@
|
||||||
|
|
||||||
(defn send-email
|
(defn send-email
|
||||||
[email]
|
[email]
|
||||||
(p/future
|
(vc/blocking
|
||||||
(let [config (get-smtp-config cfg/config)
|
(let [config (get-smtp-config cfg/config)
|
||||||
result (if (:enabled config)
|
result (if (:enabled config)
|
||||||
(postal/send-message config email)
|
(postal/send-message config email)
|
||||||
(send-email-to-console email))]
|
(send-email-to-console email))]
|
||||||
(when (not= (:error result) :SUCCESS)
|
(when (not= (:error result) :SUCCESS)
|
||||||
(ex/raise :type :sendmail-error
|
(ex/raise :type :sendmail-error
|
||||||
:code :email-not-sent
|
:code :email-not-sent
|
||||||
:context result))
|
:context result))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(defn handler
|
(defn handler
|
||||||
{:uxbox.tasks/name "sendmail"}
|
{:uxbox.tasks/name "sendmail"}
|
||||||
|
|
Loading…
Add table
Reference in a new issue