Skip to content

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

GDGT-3371: "Send Now" option for subscriptions older than v64 don't work anymore (#84426)

Anna Tomka563d044d1628
diff --git a/src/metabase/notification/models.clj b/src/metabase/notification/models.clj
index ed19d2dcfcf..3614c13e53f 100644
--- a/src/metabase/notification/models.clj
+++ b/src/metabase/notification/models.clj
@@ -474,12 +474,14 @@
[:card {:optional true} [:maybe [:merge
::queries.schema/card.update
[:map {:closed true}
- [:id ms/PositiveInt]
+ [:id ms/PositiveInt]
;; a metric's Card row describes its query on the way out of the database
- [:query_description {:optional true} [:maybe :string]]
- [:created_at {:optional true} RowTimestamp]
- [:updated_at {:optional true} RowTimestamp]
- [:last_used_at {:optional true} RowTimestamp]]]]]
+ [:query_description {:optional true} [:maybe :string]]
+ [:created_at {:optional true} RowTimestamp]
+ [:updated_at {:optional true} RowTimestamp]
+ [:last_used_at {:optional true} RowTimestamp]
+ [:cache_invalidated_at {:optional true} RowTimestamp]
+ [:initially_published_at {:optional true} RowTimestamp]]]]]
[:send_condition {:optional true} (ms/enum-decode-keyword card-subscription-send-conditions)]
[:send_once {:optional true} :boolean]
[:disable_links {:optional true} [:maybe :boolean]]
diff --git a/test/metabase/notification/api/notification_test.clj b/test/metabase/notification/api/notification_test.clj
index f1ed24ea9af..a800bdc3148 100644
--- a/test/metabase/notification/api/notification_test.clj
+++ b/test/metabase/notification/api/notification_test.clj
@@ -1435,3 +1435,23 @@
(is (=? {:channel/email [{:recipients ["[email protected]"]}]}
(notification.tu/with-captured-channel-send!
(mt/user-http-request :crowberto :post 204 "notification/send" echoed)))))))))
+
+(deftest send-unsaved-notification-echoed-card-timestamps-test
+ (testing "POST /api/notification/send accepts a saved notification sent back as fetched, card timestamps included"
+ (notification.tu/with-card-notification
+ [{notification-id :id}
+ {:card {:cache_invalidated_at (t/offset-date-time)
+ :initially_published_at (t/offset-date-time)}
+ :handlers [{:channel_type :channel/email
+ :recipients [{:type :notification-recipient/user
+ :user_id (mt/user->id :crowberto)}]}]
+ :subscriptions [{:type :notification-subscription/cron
+ :cron_schedule "0 0 0 * * ?"}]}]
+ (notification.tu/with-channel-fixtures [:channel/email]
+ (let [echoed (mt/user-http-request :crowberto :get 200 (format "notification/%d" notification-id))]
+ (is (=? {:cache_invalidated_at some?
+ :initially_published_at some?}
+ (get-in echoed [:payload :card])))
+ (is (=? {:channel/email [{:recipients ["[email protected]"]}]}
+ (notification.tu/with-captured-channel-send!
+ (mt/user-http-request :crowberto :post 204 "notification/send" echoed)))))))))