From 9b71e04e1cffc19e40043a8db37a8dbc9a019046 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 25 Nov 2024 09:28:06 +0100 Subject: [PATCH 1/3] :bug: Fix exception on user-feedback rpc method And normalizes configuration parameters --- backend/src/app/email.clj | 14 ++++++-------- backend/src/app/rpc/commands/feedback.clj | 12 +++++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/backend/src/app/email.clj b/backend/src/app/email.clj index a8ee40c4d..5bcf741f1 100644 --- a/backend/src/app/email.clj +++ b/backend/src/app/email.clj @@ -226,8 +226,8 @@ [:priority {:optional true} [:enum :high :low]] [:extra-data {:optional true} ::sm/text]]) -(def ^:private valid-context? - (sm/validator schema:context)) +(def ^:private check-context + (sm/check-fn schema:context)) (defn template-factory [& {:keys [id schema]}] @@ -236,10 +236,8 @@ (sm/check-fn schema) (constantly nil))] (fn [context] - (assert (valid-context? context) "expected a valid context") - (check-fn context) - - (let [email (build-email-template id context)] + (let [context (-> context check-context check-fn) + email (build-email-template id context)] (when-not email (ex/raise :type :internal :code :email-template-does-not-exists @@ -271,7 +269,7 @@ "Schedule an already defined email to be sent using asynchronously using worker task." [{:keys [::conn ::factory] :as context}] - (assert (db/connection? conn) "expected a valid database connection") + (assert (db/connectable? conn) "expected a valid database connection or pool") (let [email (if factory (factory context) @@ -348,7 +346,7 @@ [:subject ::sm/text] [:content ::sm/text]]) -(def feedback +(def user-feedback "A profile feedback email." (template-factory :id ::feedback diff --git a/backend/src/app/rpc/commands/feedback.clj b/backend/src/app/rpc/commands/feedback.clj index c641a4ff4..e3525ded4 100644 --- a/backend/src/app/rpc/commands/feedback.clj +++ b/backend/src/app/rpc/commands/feedback.clj @@ -17,7 +17,7 @@ [app.rpc.doc :as-alias doc] [app.util.services :as sv])) -(declare ^:private send-feedback!) +(declare ^:private send-user-feedback!) (def ^:private schema:send-user-feedback [:map {:title "send-user-feedback"} @@ -34,14 +34,16 @@ :hint "feedback not enabled")) (let [profile (profile/get-profile pool profile-id)] - (send-feedback! pool profile params) + (send-user-feedback! pool profile params) nil)) -(defn- send-feedback! +(defn- send-user-feedback! [pool profile params] - (let [dest (cf/get :feedback-destination)] + (let [dest (or (cf/get :user-feedback-destination) + ;; LEGACY + (cf/get :feedback-destination))] (eml/send! {::eml/conn pool - ::eml/factory eml/feedback + ::eml/factory eml/user-feedback :from dest :to dest :profile profile From 3ddd45e99b908debba555ca24f85b935627d7209 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 25 Nov 2024 09:53:49 +0100 Subject: [PATCH 2/3] :bug: Fix incorrect internal form initialization --- frontend/src/app/main/ui/dashboard/team_form.cljs | 4 +++- frontend/src/app/util/forms.cljs | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/ui/dashboard/team_form.cljs b/frontend/src/app/main/ui/dashboard/team_form.cljs index cf8796b75..631b17556 100644 --- a/frontend/src/app/main/ui/dashboard/team_form.cljs +++ b/frontend/src/app/main/ui/dashboard/team_form.cljs @@ -73,7 +73,9 @@ {::mf/register modal/components ::mf/register-as :team-form} [{:keys [team] :as props}] - (let [initial (mf/use-memo (fn [] (or team {}))) + (let [initial (mf/use-memo (fn [] + (or (some-> team (select-keys [:name :id])) + {}))) form (fm/use-form :schema schema:team-form :initial initial) handle-keydown diff --git a/frontend/src/app/util/forms.cljs b/frontend/src/app/util/forms.cljs index e5b710aba..f628b06b2 100644 --- a/frontend/src/app/util/forms.cljs +++ b/frontend/src/app/util/forms.cljs @@ -148,9 +148,7 @@ (mf/set-ref-val! internal-state initial)) (mf/with-effect [initial] - (if (fn? initial) - (swap! form-mutator update :data merge (initial)) - (swap! form-mutator update :data merge initial))) + (swap! form-mutator d/deep-merge initial)) form-mutator)) From 660bc1a4dd5fe9ad79b48be6a4d54ca971d85120 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 25 Nov 2024 09:55:40 +0100 Subject: [PATCH 3/3] :bug: Fix incorrect team rename operation --- frontend/src/app/main/data/dashboard.cljs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index e4530c9f9..404fb8bf0 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -450,7 +450,9 @@ (ptk/reify ::update-team ptk/UpdateEvent (update [_ state] - (assoc-in state [:teams id :name] name)) + (-> state + (assoc-in [:teams id :name] name) + (assoc-in [:team :name] name))) ptk/WatchEvent (watch [_ _ _]