Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Fix mailto link in user-joined admin notification email (#83950)

Juanc03796294d2d
diff --git a/dev/email-preview/sample-contexts.js b/dev/email-preview/sample-contexts.js
index d503a24f003..1ba5f93dcc3 100644
--- a/dev/email-preview/sample-contexts.js
+++ b/dev/email-preview/sample-contexts.js
@@ -97,7 +97,6 @@ window.SAMPLE_CONTEXTS = {
joinedViaSSO: false,
joinedUserEmail: "[email protected]",
joinedDate: "Friday, July 10",
- adminEmail: "[email protected]",
joinedUserEditUrl: "http://localhost:3000/admin/people",
},
diff --git a/src/metabase/channel/email/messages.clj b/src/metabase/channel/email/messages.clj
index b2cc96051e1..dc5c29ab12e 100644
--- a/src/metabase/channel/email/messages.clj
+++ b/src/metabase/channel/email/messages.clj
@@ -159,10 +159,7 @@
(defn all-admin-recipients
"Return a sequence of email addresses for all Admin users who have accepted their invitation (i.e. have logged in at
least once). Admins who have been invited but not yet accepted are excluded — they shouldn't receive notifications
- about activity in an instance they haven't joined.
-
- The first recipient will be the site admin (or oldest accepted admin if unset), which is the address that should be
- used in `mailto` links (e.g., for the new user to email with any questions)."
+ about activity in an instance they haven't joined. The site admin email, if set, comes first."
[]
(concat (when-let [admin-email (system/admin-email)]
[admin-email])
@@ -189,7 +186,6 @@
:joinedViaSSO google-auth?
:joinedUserEmail (:email new-user)
:joinedDate (t/format "EEEE, MMMM d" (t/zoned-date-time)) ; e.g. "Wednesday, July 13".
- :adminEmail (first recipients)
:joinedUserEditUrl (str (system/site-url) "/admin/people")})})))
(defn send-password-reset-email!
diff --git a/src/metabase/channel/email/user_joined_notification.hbs b/src/metabase/channel/email/user_joined_notification.hbs
index 467700b02d0..e41a144e152 100644
--- a/src/metabase/channel/email/user_joined_notification.hbs
+++ b/src/metabase/channel/email/user_joined_notification.hbs
@@ -17,7 +17,7 @@
</h1>
<p style="text-align: center; font-size: 15px; line-height: 165%; color: #2F3C45; margin: 0;">
- <a href="mailto:{{{adminEmail}}}" style="color: {{context.application_color}}; text-decoration: none;">{{joinedUserEmail}}</a>
+ <a href="mailto:{{{joinedUserEmail}}}" style="color: {{context.application_color}}; text-decoration: none;">{{joinedUserEmail}}</a>
joined {{#if joinedViaSSO}}via Single Sign-On {{/if}}on {{joinedDate}}.
</p>
diff --git a/test/metabase/channel/email/messages_test.clj b/test/metabase/channel/email/messages_test.clj
index e6d4b990136..77430e0ea10 100644
--- a/test/metabase/channel/email/messages_test.clj
+++ b/test/metabase/channel/email/messages_test.clj
@@ -45,6 +45,18 @@
(get-in [0 :body 0 :content])
(str/includes? "deactivated"))))))
+(deftest user-joined-admin-notification-email-test
+ (testing "the joined user's email links to the joined user, not to an admin"
+ (mt/with-temporary-setting-values [admin-email "[email protected]"]
+ (et/with-fake-inbox
+ (messages/send-user-joined-admin-notification-email! {:first_name "New"
+ :common_name "New User"
+ :email "[email protected]"})
+ (let [content (-> (@et/inbox "[email protected]")
+ (get-in [0 :body 0 :content]))]
+ (is (str/includes? content "href=\"mailto:[email protected]\""))
+ (is (not (str/includes? content "mailto:[email protected]"))))))))
+
#_(deftest render-pulse-email-test
(testing "Email with few rows and columns can be rendered when tracing (#21166)"
(mt/with-log-level [metabase.channel.email :trace]