feat(notify): name regions and link the console in alerts; consent to subscribe
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m8s
ci / test (pull_request) Successful in 13m45s
ci / build (pull_request) Successful in 19m0s
ci / image (pull_request) Successful in 6m5s

Alert mails and chat messages named regions by id. They now show the
region's name and mails link the monitor in the console.

Visitors of a status page accept the platform's terms and the page's
privacy policy, where set, before they can subscribe to it; the status
page server and the API both check it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-26 20:16:28 +01:00
1 parent cca4e80e54
commit 2d4bd10c9b
16 files changed
+660 -479

No files matched your search

+23 -8
View File
@@ -95,13 +95,28 @@ func TestStatusPageSubscriptions(t *testing.T) {
return out
}
if code, html, _ := visit("GET", "/"+slug, ""); code != 200 || !strings.Contains(html, `action="/`+slug+`/subscribe"`) || !strings.Contains(html, "feed.rss") {
// Subscribers accept the page's privacy policy.
if st, body := owner.do("PUT", "/api/v1/org/legal/privacy", map[string]any{"url": "https://shop.example/privacy"}); st != http.StatusNoContent {
t.Fatalf("set privacy policy = %d %v", st, body)
}
t.Cleanup(func() { owner.do("PUT", "/api/v1/org/legal/privacy", map[string]any{}) })
pages.Sync(ctx)
code, html, _ := visit("GET", "/"+slug, "")
if code != 200 || !strings.Contains(html, `action="/`+slug+`/subscribe"`) || !strings.Contains(html, "feed.rss") {
t.Fatalf("page = %d, want the subscription form and the feed link", code)
}
if code, html, _ := visit("POST", "/"+slug+"/subscribe", "email=not-an-address"); code != http.StatusUnprocessableEntity {
if !strings.Contains(html, `name="accept"`) || !strings.Contains(html, `href="https://shop.example/privacy"`) {
t.Error("the subscription form does not ask to accept the privacy policy")
}
if code, html, _ := visit("POST", "/"+slug+"/subscribe", "email=not-an-address&accept=1"); code != http.StatusUnprocessableEntity {
t.Errorf("subscribing an invalid address = %d %.200s", code, html)
}
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=Visitor@Example.test"); code != 200 {
visitor = "198.51.100.9:1234" // (not to use up the subscription requests of the first)
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=visitor@example.test"); code != http.StatusUnprocessableEntity {
t.Errorf("subscribing without accepting the privacy policy = %d, want 422", code)
}
visitor = "198.51.100.7:1234"
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=Visitor@Example.test&accept=1"); code != 200 {
t.Fatalf("subscribe = %d", code)
}
if c, p := subscribers(); c != 0 || p != 1 {
@@ -134,7 +149,7 @@ func TestStatusPageSubscriptions(t *testing.T) {
t.Errorf("subscribers after confirming = %d, %d; want 1, 0", c, p)
}
// Asking again for a confirmed address mails nothing.
visit("POST", "/"+slug+"/subscribe", "email=visitor@example.test")
visit("POST", "/"+slug+"/subscribe", "email=visitor@example.test&accept=1")
if n := len(mailsTo("visitor@example.test")); n != 1 {
t.Errorf("mails after subscribing a confirmed address again = %d, want 1", n)
}
@@ -199,10 +214,10 @@ func TestStatusPageSubscriptions(t *testing.T) {
}); err != nil {
t.Fatal(err)
}
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=second@example.test"); code != 200 {
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=second@example.test&accept=1"); code != 200 {
t.Errorf("subscription within the weekly limit = %d", code)
}
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=third@example.test"); code != http.StatusTooManyRequests {
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=third@example.test&accept=1"); code != http.StatusTooManyRequests {
t.Errorf("subscription beyond the weekly limit = %d, want 429", code)
}
if n := len(mailsTo("third@example.test")); n != 0 {
@@ -218,13 +233,13 @@ func TestStatusPageSubscriptions(t *testing.T) {
if code, html, _ := visit("GET", "/"+slug, ""); code != 200 || strings.Contains(html, "/subscribe\"") {
t.Errorf("page without subscriptions = %d, still offers the form", code)
}
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=fourth@example.test"); code != http.StatusNotFound {
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=fourth@example.test&accept=1"); code != http.StatusNotFound {
t.Errorf("subscribing where it is off = %d, want 404", code)
}
// This visitor used up its subscription requests on the server.
visitor = "198.51.100.7:1234"
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=fifth@example.test"); code != http.StatusTooManyRequests {
if code, _, _ := visit("POST", "/"+slug+"/subscribe", "email=fifth@example.test&accept=1"); code != http.StatusTooManyRequests {
t.Errorf("sixth subscription request of a visitor = %d, want 429", code)
}