0
Fork 0
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:
Andrey Antukh 2020-02-05 12:51:55 +01:00
parent 460019e01b
commit b4790c89ce
4 changed files with 26 additions and 14 deletions

View file

@ -47,6 +47,7 @@
(s/def ::email-reply-to ::us/email)
(s/def ::email-from ::us/email)
(s/def ::smtp-host ::us/string)
(s/def ::smtp-port ::us/integer)
(s/def ::smtp-user (s/nilable ::us/string))
(s/def ::smtp-password (s/nilable ::us/string))
(s/def ::smtp-tls ::us/boolean)
@ -70,6 +71,7 @@
::email-reply-to
::email-from
::smtp-host
::smtp-port
::smtp-user
::smtp-password
::smtp-tls

View file

@ -254,7 +254,7 @@
(let [data {:to (:email params)
:name (:fullname params)}]
(p/do!
(emails/send! emails/register data)
(emails/send! conn emails/register data)
profile))))))
;; --- Mutation: Request Profile Recovery

View file

@ -102,6 +102,13 @@
(cond-> row
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
[{:keys [tasks] :as options}]
(let [queue (:queue options "default")
@ -114,9 +121,11 @@
(-> (p/do! (handle-task tasks item))
(p/handle (fn [v e]
(if e
(if (>= (:retry-num item) max-retries)
(mark-as-failed conn item e)
(reschedule conn item e))
(do
(log-error item e)
(if (>= (:retry-num item) max-retries)
(mark-as-failed conn item e)
(reschedule conn item e)))
(mark-as-completed conn item))))
(p/then' (constantly ::handled))))))))))

View file

@ -13,6 +13,7 @@
[clojure.tools.logging :as log]
[cuerdas.core :as str]
[postal.core :as postal]
[vertx.core :as vc]
[promesa.core :as p]
[uxbox.common.exceptions :as ex]
[uxbox.config :as cfg]
@ -48,16 +49,16 @@
(defn send-email
[email]
(p/future
(let [config (get-smtp-config cfg/config)
result (if (:enabled config)
(postal/send-message config email)
(send-email-to-console email))]
(when (not= (:error result) :SUCCESS)
(ex/raise :type :sendmail-error
:code :email-not-sent
:context result))
nil)))
(vc/blocking
(let [config (get-smtp-config cfg/config)
result (if (:enabled config)
(postal/send-message config email)
(send-email-to-console email))]
(when (not= (:error result) :SUCCESS)
(ex/raise :type :sendmail-error
:code :email-not-sent
:context result))
nil)))
(defn handler
{:uxbox.tasks/name "sendmail"}