🎉 Add automatic complaint and bouncing handling.

This commit is contained in:
Andrey Antukh 2021-02-11 17:57:41 +01:00
parent 17229228a3
commit 7708752ad9
26 changed files with 1073 additions and 73 deletions

View file

@ -40,14 +40,20 @@
(s/keys :req-un [::email-1 ::email-2]))
(defn- on-error
[form error]
(cond
(= (:code error) :email-already-exists)
[form {:keys [code] :as error}]
(case code
:email-already-exists
(swap! form (fn [data]
(let [error {:message (tr "errors.email-already-exists")}]
(assoc-in data [:errors :email-1] error))))
:else
:profile-is-muted
(rx/of (dm/error (tr "errors.profile-is-muted")))
:email-has-permanent-bounces
(let [email (get @form [:data email])]
(rx/of (dm/error (tr "errors.email-has-permanent-bounces" email))))
(rx/throw error)))
(defn- on-success