feat(statuspages): email subscriptions, RSS feed and a JSON API
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Successful in 9m5s
ci / lint (pull_request) Successful in 10m24s
ci / build (pull_request) Successful in 18m10s
ci / image (pull_request) Successful in 5m16s

Visitors can subscribe to a page's incidents by email where the
organization allows it. They confirm their address first; confirmation
and unsubscribe links only show a button, so mail scanners do not act on
them, and mails carry RFC 8058 one-click unsubscribe headers. Subscribers
get a mail when an incident opens or resolves and for every public
update.

Every page also has an RSS feed of incidents and planned maintenance and
a read-only JSON API (status, summary, components, incidents), both
served from the cached snapshot.

Abuse protection: status page servers limit feed and API reads,
subscription requests and link actions per visitor; the API limits
subscription requests per visitor, mailbox and page, and a new limit caps
the subscriptions an organization's pages gain in seven days (platform
default and per-organization override, 1000 in the cloud). Unconfirmed
subscriptions count towards it and are deleted after a week.

The fixed cap of 200 monitors per status page is gone; the configurable
limit alone decides.

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 18:18:08 +01:00
1 parent df39b765cb
commit cca4e80e54
39 files changed
+4332 -1408

No files matched your search

+66
View File
@@ -2,6 +2,7 @@ package web
import (
"strconv"
"strings"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
)
@@ -120,6 +121,15 @@ type PageEditor struct {
DomainChangesPerDay int
// MonitorLimit is how many monitors the page may show; 0 is any.
MonitorLimit int
// Subscriptions lets visitors subscribe by email; MailAvailable says
// whether the platform can send mail at all.
Subscriptions bool
MailAvailable bool
// SubscriberLimit is the organization's weekly limit; 0 is any.
SubscriberLimit int
SubscribersConfirmed int
SubscribersPending int
Subscribers []PageSubscriberRow
RecordName string
RecordValue string
Suspended bool
@@ -166,6 +176,13 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) {
@checkbox(i18n.T(ctx, "pages.published"), "published", e.Published)
@checkbox(i18n.T(ctx, "pages.show_details"), "show_component_details", e.ShowDetails)
<p class="-mt-2 mb-4 text-xs text-muted">{ i18n.T(ctx, "pages.show_details_hint") }</p>
@checkbox(i18n.T(ctx, "pages.subscriptions"), "subscriptions", e.Subscriptions)
<p class="-mt-2 mb-4 text-xs text-muted">
{ i18n.T(ctx, "pages.subscriptions_hint") }
if !e.MailAvailable {
{ " " + i18n.T(ctx, "pages.subscriptions_no_mail") }
}
</p>
<h3 class="mt-6 mb-3 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "pages.theme") }</h3>
@valueField(i18n.T(ctx, "pages.accent"), "theme.accent", e.Accent, "#1f6feb", false)
@valueField(i18n.T(ctx, "pages.logo"), "theme.logo_url", e.LogoURL, "https://example.com/logo.svg", false)
@@ -182,6 +199,20 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) {
data-next="/statuspages"
class="mt-6 text-sm text-down hover:underline"
>{ i18n.T(ctx, "pages.delete") }</button>
if e.URL != "" {
<section class="mt-12">
@sectionHeading("pages.feeds")
<p class="mb-2 text-sm text-muted">{ i18n.T(ctx, "pages.feeds_hint") }</p>
<ul class="space-y-1 font-mono text-xs">
for _, path := range []string{"feed.rss", "api/v1/status", "api/v1/summary", "api/v1/components", "api/v1/incidents"} {
<li><a href={ templ.SafeURL(strings.TrimSuffix(e.URL, "/") + "/" + path) } target="_blank" rel="noopener" class="hover:underline">{ strings.TrimSuffix(e.URL, "/") + "/" + path }</a></li>
}
</ul>
</section>
}
if e.Subscriptions || e.SubscribersConfirmed+e.SubscribersPending > 0 {
@pageSubscribers(e)
}
</section>
<div>
<section class="mb-12">
@@ -398,3 +429,38 @@ templ pageMonitorFields(e PageEditor, m PageMonitorOption) {
<input data-field="label" value={ m.Label } placeholder={ i18n.T(ctx, "pages.label") } class="w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink"/>
</span>
}
// PageSubscriberRow is an email subscriber of a page.
type PageSubscriberRow struct {
ID, Email, Since string
Pending bool
}
templ pageSubscribers(e PageEditor) {
<section id="subscribers" class="mt-12">
@sectionHeading("pages.subscribers")
<p class="mb-2 text-sm">{ i18n.T(ctx, "pages.subscribers_counts", "Confirmed", e.SubscribersConfirmed, "Pending", e.SubscribersPending) }</p>
if e.SubscriberLimit > 0 {
<p class="mb-3 text-xs text-muted">{ i18n.T(ctx, "pages.subscribers_limit", "Max", e.SubscriberLimit) }</p>
}
if len(e.Subscribers) == 0 {
<p class="text-sm text-muted">{ i18n.T(ctx, "pages.subscribers_none") }</p>
} else {
<ul class="divide-y divide-rule border-y border-rule text-sm">
for _, sub := range e.Subscribers {
<li class="flex flex-wrap items-baseline gap-x-3 gap-y-1 py-2">
<span class="font-mono text-xs">{ sub.Email }</span>
if sub.Pending {
<span class="text-xs text-muted">{ i18n.T(ctx, "pages.subscriber_pending") }</span>
}
<span class="ml-auto font-mono text-xs text-muted">{ sub.Since }</span>
<button type="button" data-delete={ "/org/statuspages/" + e.ID + "/subscribers/" + sub.ID } data-next={ "/statuspages/" + e.ID + "#subscribers" } class="text-xs text-muted hover:text-down">{ i18n.T(ctx, "pages.subscriber_remove") }</button>
</li>
}
</ul>
if len(e.Subscribers) < e.SubscribersConfirmed+e.SubscribersPending {
<p class="mt-2 text-xs text-muted">{ i18n.T(ctx, "pages.subscribers_more", "Count", len(e.Subscribers)) }</p>
}
}
</section>
}