diff --git a/backend/src/app/emails.clj b/backend/src/app/emails.clj index 6721c299c..1a5aebb63 100644 --- a/backend/src/app/emails.clj +++ b/backend/src/app/emails.clj @@ -8,6 +8,7 @@ "Main api for send emails." (:require [app.common.logging :as l] + [app.common.pprint :as pp] [app.common.spec :as us] [app.config :as cf] [app.db :as db] @@ -165,19 +166,25 @@ (let [enabled? (or (contains? cf/flags :smtp) (cf/get :smtp-enabled) (:enabled task))] - (if enabled? - (emails/send! cfg props) + (when enabled? + (emails/send! cfg props)) + + (when (contains? cf/flags :log-emails) (send-console! cfg props))))) (defn- send-console! [cfg email] - (let [baos (java.io.ByteArrayOutputStream.) - mesg (emails/smtp-message cfg email)] - (.writeTo mesg baos) - (let [out (with-out-str - (println "email console dump:") - (println "******** start email" (:id email) "**********") - (println (.toString baos)) - (println "******** end email "(:id email) "**********"))] - (l/info :email out)))) + (let [body (:body email) + out (with-out-str + (println "email console dump:") + (println "******** start email" (:id email) "**********") + (pp/pprint (dissoc email :body)) + (if (string? body) + (println body) + (println (->> body + (filter #(= "text/plain" (:type %))) + (map :content) + first))) + (println "******** end email" (:id email) "**********"))] + (l/info ::l/raw out))) diff --git a/backend/src/app/rpc/mutations/teams.clj b/backend/src/app/rpc/mutations/teams.clj index ce5626d16..586a9ad60 100644 --- a/backend/src/app/rpc/mutations/teams.clj +++ b/backend/src/app/rpc/mutations/teams.clj @@ -8,6 +8,7 @@ (:require [app.common.data :as d] [app.common.exceptions :as ex] + [app.common.logging :as l] [app.common.spec :as us] [app.common.uuid :as uuid] [app.config :as cf] @@ -412,6 +413,9 @@ {:iss :profile-identity :profile-id (:id profile)})] + (when (contains? cf/flags :log-invitation-tokens) + (l/trace :hint "invitation token" :token itoken)) + (when (and member (not (eml/allow-send-emails? conn member))) (ex/raise :type :validation :code :member-is-muted