The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Skip API-key users when expanding notification recipients (#73922)
Ngoc Khuat87abb0fe6b3a
diff --git a/src/metabase/channel/impl/email.clj b/src/metabase/channel/impl/email.cljindex b6fc884cc17..d428dd26880 100644--- a/src/metabase/channel/impl/email.clj+++ b/src/metabase/channel/impl/email.clj@@ -315,9 +315,12 @@:let [details (:details recipient)emails (case (:type recipient):notification-recipient/user- [(-> recipient :user :email)]+ (when (not= :api-key (-> recipient :user :type))+ [(-> recipient :user :email)]):notification-recipient/group- (->> recipient :permissions_group :members (map :email))+ (->> recipient :permissions_group :members+ (remove #(= :api-key (:type %)))+ (map :email)):notification-recipient/raw-value[(:value details)]:notification-recipient/templatediff --git a/src/metabase/permissions/models/permissions_group.clj b/src/metabase/permissions/models/permissions_group.cljindex e0bd730e1a2..11f5d9e42b9 100644--- a/src/metabase/permissions/models/permissions_group.clj+++ b/src/metabase/permissions/models/permissions_group.clj@@ -165,6 +165,7 @@:u.last_name:u.email:u.is_superuser+ :u.type:pgm.group_id[:pgm.id :membership_id](when (premium-features/enable-advanced-permissions?)diff --git a/test/metabase/channel/impl/email_test.clj b/test/metabase/channel/impl/email_test.cljindex a9f7c057242..8627900eda7 100644--- a/test/metabase/channel/impl/email_test.clj+++ b/test/metabase/channel/impl/email_test.clj@@ -118,6 +118,18 @@{:template-type :email/handlebars-resource:channel-type :channel/email})))))))+(deftest notification-recipients-skips-api-key-users-test+ (testing "API-key users are filtered out of notification recipients (GDGT-2402)"+ (let [recipients [{:type :notification-recipient/group+ :permissions_group {:members [{:email "[email protected]" :type :personal}+ {:email "[email protected]" :type :api-key}]}}+ {:type :notification-recipient/user+ :user {:email "[email protected]" :type :api-key}}+ {:type :notification-recipient/raw-value+ :details {:value "[email protected]"}}]]+ (is (= ["[email protected]" "[email protected]"]+ (#'email.impl/notification-recipients->emails recipients {}))))))+(deftest render-body-logging-test(testing "rendering a user-provided template logs the template body at debug level"(mt/with-log-messages-for-level [messages :debug]