Skip to content
Snippets Groups Projects
Unverified Commit 13d2e44c authored by Ryan Senior's avatar Ryan Senior Committed by GitHub
Browse files

Merge pull request #6424 from metabase/fix-email-to-address-order

Compare email 'to` as a set, not a vector
parents e29bae68 fbafdec5
No related branches found
No related tags found
No related merge requests found
......@@ -193,18 +193,19 @@
"confirmation that your alert" false}))]
(with-alert-setup
[(-> ((alert-client :crowberto) :post 200 "alert"
{:card {:id (:id card1)}
:alert_condition "rows"
:alert_first_only false
:channels [{:enabled true
:channel_type "email"
:schedule_type "daily"
:schedule_hour 12
:schedule_day nil
:details {:emails nil}
:recipients (mapv fetch-user [:crowberto :rasta])}]})
setify-recipient-emails)
[(et/with-expected-messages 2
(-> ((alert-client :crowberto) :post 200 "alert"
{:card {:id (:id card1)}
:alert_condition "rows"
:alert_first_only false
:channels [{:enabled true
:channel_type "email"
:schedule_type "daily"
:schedule_hour 12
:schedule_day nil
:details {:emails nil}
:recipients (mapv fetch-user [:crowberto :rasta])}]})
setify-recipient-emails))
(et/regex-email-bodies #"https://metabase.com/testmb"
#"now getting alerts"
#"confirmation that your alert"
......
......@@ -116,10 +116,10 @@
;; Archiving a collection should delete any alerts associated with questions in the collection
(tt/expect-with-temp [Collection [{collection-id :id}]
Card [{card-id :id :as card} {:collection_id collection-id}]
Pulse [{pulse-id :id} {:alert_condition "rows"
:alert_first_only false
:creator_id (user->id :rasta)
:name "Original Alert Name"}]
Pulse [{pulse-id :id} {:alert_condition "rows"
:alert_first_only false
:creator_id (user->id :rasta)
:name "Original Alert Name"}]
PulseCard [_ {:pulse_id pulse-id
:card_id card-id
......@@ -129,14 +129,11 @@
:pulse_channel_id pc-id}]
PulseChannelRecipient [{pcr-id-2 :id} {:user_id (user->id :rasta)
:pulse_channel_id pc-id}]]
[{"crowberto@metabase.com" [{:from "notifications@metabase.com",
:to ["crowberto@metabase.com"],
:subject "One of your alerts has stopped working",
:body {"the question was archived by Crowberto Corv" true}}],
"rasta@metabase.com" [{:from "notifications@metabase.com",
:to ["rasta@metabase.com"],
:subject "One of your alerts has stopped working",
:body {"the question was archived by Crowberto Corv" true}}]}
[(merge (et/email-to :crowberto {:subject "One of your alerts has stopped working",
:body {"the question was archived by Crowberto Corv" true}})
(et/email-to :rasta {:subject "One of your alerts has stopped working",
:body {"the question was archived by Crowberto Corv" true}}))
nil]
(et/with-fake-inbox
(et/with-expected-messages 2
......
......@@ -95,7 +95,9 @@
(let [email-body->regex-boolean (create-email-body->regex-fn regexes)]
(m/map-vals (fn [emails-for-recipient]
(for [email emails-for-recipient]
(update email :body (comp email-body->regex-boolean first))))
(-> email
(update :to set)
(update :body (comp email-body->regex-boolean first)))))
@inbox)))
(defn- mime-type [mime-type-str]
......@@ -116,11 +118,13 @@
(let [email-body->regex-boolean (create-email-body->regex-fn regexes)]
(m/map-vals (fn [emails-for-recipient]
(for [email emails-for-recipient]
(update email :body (fn [email-body-seq]
(for [{email-type :type :as email-part} email-body-seq]
(if (string? email-type)
(email-body->regex-boolean email-part)
(summarize-attachment email-part)))))))
(-> email
(update :to set)
(update :body (fn [email-body-seq]
(for [{email-type :type :as email-part} email-body-seq]
(if (string? email-type)
(email-body->regex-boolean email-part)
(summarize-attachment email-part))))))))
@inbox)))
(defn email-to
......@@ -128,7 +132,7 @@
[user-kwd & [email-map]]
(let [{:keys [email]} (user/fetch-user user-kwd)]
{email [(merge {:from "notifications@metabase.com",
:to [email]}
:to #{email}}
email-map)]}))
;; simple test of email sending capabilities
......
......@@ -102,7 +102,7 @@
:pulse_channel_id pc-id}]]
(into {} (map (fn [user-kwd]
(et/email-to user-kwd {:subject "Pulse: Pulse Name",
:to ["rasta@metabase.com" "crowberto@metabase.com"]
:to #{"rasta@metabase.com" "crowberto@metabase.com"}
:body [{"Pulse Name" true}
png-attachment]}))
[:rasta :crowberto]))
......
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