Skip to content
Snippets Groups Projects
Unverified Commit bd8fe4a9 authored by Jerry Huang's avatar Jerry Huang Committed by GitHub
Browse files

Add public setting to opt-in to CC recipients (#34621)

parent b55da4db
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
[medley.core :as m]
[metabase-enterprise.test :as met]
[metabase.api.alert :as api.alert]
[metabase.email :as email]
[metabase.email.messages :as messages]
[metabase.models
:refer [Card Pulse PulseCard PulseChannel PulseChannelRecipient]]
......@@ -59,6 +60,30 @@
(m/dissoc-in results ["rasta@metabase.com" 0 :body])))
(get-in results ["rasta@metabase.com" 0 :body 0 :result]))))))
(deftest bcc-enabled-pulse-test
(testing "When bcc is not enabled, return an email that uses to:"
(mt/with-temp [Card pulse-card {}
Pulse pulse {:name "Test Pulse"}
PulseCard _ {:pulse_id (:id pulse), :card_id (:id pulse-card)}
PulseChannel pc {:channel_type :email
:pulse_id (:id pulse)
:enabled true}
PulseChannelRecipient _ {:pulse_channel_id (:id pc)
:user_id (mt/user->id :rasta)}]
(mt/with-temporary-setting-values [email-from-address "metamailman@metabase.com"]
(mt/with-fake-inbox
(with-redefs [messages/render-pulse-email (fn [_ _ _ [{:keys [result]}] _]
[{:result result}])
email/bcc-enabled? (constantly false)]
(mt/with-test-user nil
(metabase.pulse/send-pulse! pulse)))
(let [results @mt/inbox]
(is (= {"rasta@metabase.com" [{:from "metamailman@metabase.com"
:to ["rasta@metabase.com"]
:subject "Pulse: Test Pulse"}]}
(m/dissoc-in results ["rasta@metabase.com" 0 :body])))
(get-in results ["rasta@metabase.com" 0 :body 0 :result])))))))
(deftest e2e-sandboxed-pulse-test
(testing "Sending Pulses w/ sandboxing, end-to-end"
(met/with-gtaps {:gtaps {:venues {:query (mt/mbql-query venues
......
......@@ -29,6 +29,12 @@
(deferred-tru "The name you want to use for the sender of emails.")
:visibility :settings-manager)
(defsetting bcc-enabled?
(deferred-tru "Whether or not bcc emails are enabled, default behavior is that it is")
:visibility :settings-manager
:type :boolean
:default true)
(def ^:private ReplyToAddresses
[:maybe [:sequential ms/Email]])
......
......@@ -536,7 +536,7 @@
:recipients recipients
:message-type message-type
:message message
:bcc? true})
:bcc? (email/bcc-enabled?)})
(catch ExceptionInfo e
(when (not= :smtp-host-not-set (:cause (ex-data e)))
(throw e))))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment