From 9fb8ba2ff1f3deeca1545094f14a61a6ed6e5cb6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 1 Mar 2021 13:16:06 +0100 Subject: [PATCH] :tada: Add better reply-to handling on feedback module. --- backend/resources/emails/feedback/en.subj | 2 +- backend/resources/emails/feedback/en.txt | 5 ++--- backend/src/app/config.clj | 2 ++ backend/src/app/http/feedback.clj | 26 +++++++++++------------ 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/backend/resources/emails/feedback/en.subj b/backend/resources/emails/feedback/en.subj index 7b4c21809..7f1c38c4b 100644 --- a/backend/resources/emails/feedback/en.subj +++ b/backend/resources/emails/feedback/en.subj @@ -1 +1 @@ -[PENPOT FEEDBACK]: {{subject|abbreviate:19}} (from {% if profile %}{{ profile.email }}{% else %}{{from}}{% endif %}) +[PENPOT FEEDBACK]: {{subject|abbreviate:19}} (from {{email}}) diff --git a/backend/resources/emails/feedback/en.txt b/backend/resources/emails/feedback/en.txt index c768a9fd9..a60d380c8 100644 --- a/backend/resources/emails/feedback/en.txt +++ b/backend/resources/emails/feedback/en.txt @@ -1,8 +1,7 @@ {% if profile %} -Feedback from: {{profile.fullname}} <{{profile.email}}> -Profile ID: {{profile.id}} +Feedback profile: {{profile.fullname}} <{{profile.email}}> / {{profile.id}} {% else %} -Feedback from: {{from}} +Feedback from: {{email}} {% endif %} Subject: {{subject}} diff --git a/backend/src/app/config.clj b/backend/src/app/config.clj index a4f8a0817..a9fe74ac8 100644 --- a/backend/src/app/config.clj +++ b/backend/src/app/config.clj @@ -90,6 +90,7 @@ (s/def ::error-report-webhook ::us/string) (s/def ::feedback-destination ::us/string) (s/def ::feedback-enabled ::us/boolean) +(s/def ::feedback-reply-to ::us/email) (s/def ::feedback-token ::us/string) (s/def ::github-client-id ::us/string) (s/def ::github-client-secret ::us/string) @@ -163,6 +164,7 @@ ::error-report-webhook ::feedback-destination ::feedback-enabled + ::feedback-reply-to ::feedback-token ::github-client-id ::github-client-secret diff --git a/backend/src/app/http/feedback.clj b/backend/src/app/http/feedback.clj index afd952864..759b9c992 100644 --- a/backend/src/app/http/feedback.clj +++ b/backend/src/app/http/feedback.clj @@ -27,11 +27,8 @@ (defmethod ig/init-key ::handler [_ {:keys [pool] :as scfg}] - (let [ftoken (cfg/get :feedback-token ::no-token) - enabled (cfg/get :feedback-enabled) - dest (cfg/get :feedback-destination) - scfg (assoc scfg :destination dest)] - + (let [ftoken (cfg/get :feedback-token ::no-token) + enabled (cfg/get :feedback-enabled)] (fn [{:keys [profile-id] :as request}] (let [token (get-in request [:headers "x-feedback-token"]) params (d/merge (:params request) @@ -47,7 +44,7 @@ (let [profile (profile/retrieve-profile-data pool profile-id) params (assoc params :from (:email profile))] (when-not (:is-muted profile) - (send-feedback scfg profile params))) + (send-feedback pool profile params))) (= token ftoken) (send-feedback scfg nil params)) @@ -62,12 +59,15 @@ (s/keys :req-un [::from ::subject ::content])) (defn send-feedback - [{:keys [pool destination]} profile params] - (let [params (us/conform ::feedback params)] + [pool profile params] + (let [params (us/conform ::feedback params) + destination (cfg/get :feedback-destination) + reply-to (cfg/get :feedback-reply-to)] (emails/send! pool emails/feedback - {:to destination - :profile profile - :from (:from params) - :subject (:subject params) - :content (:content params)}) + {:to destination + :profile profile + :reply-to (:from params) + :email (:from params) + :subject (:subject params) + :content (:content params)}) nil))