feat(notifications): send product notifications with a rights check right before each send

This commit is contained in:
shira committed 2026-10-09 20:38:39 +03:00
1 parent a856066316
commit 623d41b969
59 files changed
+4125 -1126

No files matched your search

@@ -18,6 +18,19 @@ func TestMetricsHandlerExposesWhetherTheMailSenderRuns(t *testing.T) {
requireSeries(t, scrape(t, metrics), "lincodex_mail_sender_running 0")
}
func TestMetricsHandlerExposesWhetherTheNotificationSenderRuns(t *testing.T) {
metrics := New()
// The product loop has its own series, so the service loop's gauge keeps
// its meaning when only the product loop runs.
requireSeries(t, scrape(t, metrics), "lincodex_notification_sender_running 0")
metrics.SetNotificationSenderRunning(true)
requireSeries(t, scrape(t, metrics), "lincodex_notification_sender_running 1", "lincodex_mail_sender_running 0")
metrics.SetNotificationSenderRunning(false)
requireSeries(t, scrape(t, metrics), "lincodex_notification_sender_running 0")
}
func TestMetricsHandlerCountsCancelledMailByABoundedReason(t *testing.T) {
metrics := New()
// Every reason exists at zero before the first cancellation.
@@ -26,6 +39,9 @@ func TestMetricsHandlerCountsCancelledMailByABoundedReason(t *testing.T) {
`lincodex_mail_sender_cancelled_total{reason="content_invalid"} 0`,
`lincodex_mail_sender_cancelled_total{reason="processing_failed"} 0`,
`lincodex_mail_sender_cancelled_total{reason="token_revoked"} 0`,
`lincodex_mail_sender_cancelled_total{reason="rights_revoked"} 0`,
`lincodex_mail_sender_cancelled_total{reason="recipient_ineligible"} 0`,
`lincodex_mail_sender_cancelled_total{reason="source_closed"} 0`,
)
metrics.ObserveMailCancelled("content_invalid")
metrics.ObserveMailCancelled("content_invalid")