feat: admins suspend or delete status pages, organizations and accounts
The admin panel lists every published status page, and every suspended page, organization or account, with the organization and owner behind it, searchable by title, address, organization or email. Each can be suspended with a reason, reinstated, or deleted. A suspended page is not served; status page servers drop it when they next ask. A suspended organization's monitors leave the schedule, its pages go offline, heartbeat pings and Alertmanager webhooks are no longer recorded, and its members and API tokens get 403 org_suspended; the console explains why. Reinstating restarts heartbeat waits so they do not fire at once. A suspended account is signed out everywhere and can neither sign in nor use its tokens; only someone who knows the password learns of the suspension. Platform admins cannot be suspended or deleted. Account deletion shares its logic with the GDPR erasure, including the refusal while the account owns shared organizations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
db37060c70
commit
90e74d091a
37 files changed
+3109
-1140
No files matched your search
+163
-2
@@ -1,6 +1,10 @@
|
||||
package web
|
||||
|
||||
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
|
||||
)
|
||||
|
||||
// Region is a row in a region list.
|
||||
type Region struct {
|
||||
@@ -159,13 +163,14 @@ templ RegionsPage(p Page, me Me, v RegionsView) {
|
||||
}
|
||||
}
|
||||
|
||||
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool) {
|
||||
templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, mod ModerationView) {
|
||||
@consoleShell(p, me) {
|
||||
@settingsHeading("admin.title", "admin.intro")
|
||||
<p class="-mt-4 mb-8 flex gap-4 text-sm">
|
||||
<a href="/admin/audit" class="underline underline-offset-2">{ i18n.T(ctx, "audit.platform_title") }</a>
|
||||
<a href="/admin/legal" class="underline underline-offset-2">{ i18n.T(ctx, "legal.platform_title") }</a>
|
||||
</p>
|
||||
@moderationSection(mod)
|
||||
@regionsBody(v)
|
||||
@checkerNetworkSection(platformPrivate)
|
||||
@checkTypesSection(checkTypes, "/admin/check-types", "/admin", "admin.check_types_intro")
|
||||
@@ -211,3 +216,159 @@ templ checkTypesSection(types []CheckTypeOption, api, next, introID string) {
|
||||
</form>
|
||||
</section>
|
||||
}
|
||||
|
||||
// ModerationView lists public status pages for platform admins.
|
||||
type ModerationView struct {
|
||||
Search string
|
||||
Pages []ModeratedPage
|
||||
// Limited is set when more pages match than are shown.
|
||||
Limited bool
|
||||
}
|
||||
|
||||
// ModeratedPage is a status page with the organization and account
|
||||
// behind it.
|
||||
type ModeratedPage struct {
|
||||
ID, Title, Slug, URL, Created string
|
||||
Published bool
|
||||
Suspended string
|
||||
Org ModeratedTarget
|
||||
Owner *ModeratedTarget
|
||||
}
|
||||
|
||||
// ModeratedTarget is an organization or account that can be suspended or
|
||||
// deleted. Suspended holds the reason, or "-" without one, when suspended.
|
||||
type ModeratedTarget struct {
|
||||
ID, Name, Detail, Suspended string
|
||||
// Admin marks platform admins, who are out of reach here.
|
||||
Admin bool
|
||||
}
|
||||
|
||||
func (v ModerationView) next() string {
|
||||
if v.Search == "" {
|
||||
return "/admin#moderation"
|
||||
}
|
||||
return "/admin?q=" + url.QueryEscape(v.Search) + "#moderation"
|
||||
}
|
||||
|
||||
templ moderationSection(v ModerationView) {
|
||||
<section id="moderation" class="mb-12">
|
||||
@sectionHeading("moderation.title")
|
||||
<p class="mb-4 max-w-3xl text-sm text-muted">{ i18n.T(ctx, "moderation.intro") }</p>
|
||||
<form method="get" action="/admin#moderation" class="mb-4 flex max-w-xl gap-2">
|
||||
<input
|
||||
type="search"
|
||||
name="q"
|
||||
value={ v.Search }
|
||||
placeholder={ i18n.T(ctx, "moderation.search") }
|
||||
aria-label={ i18n.T(ctx, "moderation.search") }
|
||||
class="w-full border border-rule bg-transparent px-2.5 py-1.5 text-sm outline-none focus:border-ink"
|
||||
/>
|
||||
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "moderation.search_button") }</button>
|
||||
</form>
|
||||
if len(v.Pages) == 0 {
|
||||
<p class="text-sm text-muted">{ i18n.T(ctx, "moderation.none") }</p>
|
||||
} else {
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full min-w-[42rem] text-left text-sm">
|
||||
<thead class="border-b border-rule text-xs uppercase tracking-wider text-muted">
|
||||
<tr>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "moderation.page") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "moderation.org") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "moderation.owner") }</th>
|
||||
<th class="py-2 pr-4 font-medium">{ i18n.T(ctx, "moderation.created") }</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-rule">
|
||||
for _, pg := range v.Pages {
|
||||
<tr class="align-top">
|
||||
<td class="py-2.5 pr-4">
|
||||
<a href={ templ.SafeURL(pg.URL) } target="_blank" rel="noopener noreferrer" class="hover:underline">{ pg.Title }</a>
|
||||
<span class="block font-mono text-xs text-muted">{ pg.Slug }</span>
|
||||
@moderationState(pg.Suspended, !pg.Published)
|
||||
</td>
|
||||
<td class="py-2.5 pr-4">
|
||||
{ pg.Org.Name }
|
||||
<span class="block font-mono text-xs text-muted">{ pg.Org.Detail }</span>
|
||||
@moderationState(pg.Org.Suspended, false)
|
||||
</td>
|
||||
<td class="py-2.5 pr-4">
|
||||
if pg.Owner != nil {
|
||||
<span class="break-all">{ pg.Owner.Name }</span>
|
||||
@moderationState(pg.Owner.Suspended, false)
|
||||
} else {
|
||||
<span class="text-muted">–</span>
|
||||
}
|
||||
</td>
|
||||
<td class="py-2.5 pr-4 font-mono text-xs text-muted">{ pg.Created }</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" class="pb-3">
|
||||
<details class="text-sm">
|
||||
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "moderation.actions") }</summary>
|
||||
<div class="mt-3 grid gap-6 md:grid-cols-3">
|
||||
@moderationActions("page", "/admin/status-pages/"+pg.ID, pg.Suspended, pg.Title, v.next())
|
||||
@moderationActions("org", "/admin/orgs/"+pg.Org.ID, pg.Org.Suspended, pg.Org.Name, v.next())
|
||||
if pg.Owner != nil && pg.Owner.Admin {
|
||||
<p class="text-xs text-muted">{ i18n.T(ctx, "moderation.owner_is_admin") }</p>
|
||||
} else if pg.Owner != nil {
|
||||
@moderationActions("owner", "/admin/users/"+pg.Owner.ID, pg.Owner.Suspended, pg.Owner.Name, v.next())
|
||||
}
|
||||
</div>
|
||||
</details>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
if v.Limited {
|
||||
<p class="mt-3 text-xs text-muted">{ i18n.T(ctx, "moderation.limited") }</p>
|
||||
}
|
||||
}
|
||||
</section>
|
||||
}
|
||||
|
||||
templ moderationState(suspended string, draft bool) {
|
||||
if suspended != "" {
|
||||
<span class="mt-1 inline-block text-xs font-medium text-down">
|
||||
{ i18n.T(ctx, "moderation.suspended") }
|
||||
if suspended != "-" {
|
||||
<span class="font-normal text-muted">{ "· " + suspended }</span>
|
||||
}
|
||||
</span>
|
||||
} else if draft {
|
||||
<span class="mt-1 inline-block text-xs text-muted">{ i18n.T(ctx, "pages.draft") }</span>
|
||||
}
|
||||
}
|
||||
|
||||
// moderationActions suspends, reinstates or deletes one target; kind is
|
||||
// "page", "org" or "owner".
|
||||
templ moderationActions(kind, api, suspended, name, next string) {
|
||||
<div>
|
||||
<h4 class="mb-2 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "moderation.target_"+kind) }</h4>
|
||||
<form data-api={ api + "/suspension" } data-method="put" data-next={ next } class="mb-2">
|
||||
@formError()
|
||||
if suspended != "" {
|
||||
<input type="checkbox" name="suspended" hidden/>
|
||||
<button type="submit" class="border border-rule px-2.5 py-1 hover:border-ink">{ i18n.T(ctx, "moderation.reinstate") }</button>
|
||||
} else {
|
||||
<input type="checkbox" name="suspended" checked hidden/>
|
||||
<input
|
||||
name="reason"
|
||||
maxlength="500"
|
||||
placeholder={ i18n.T(ctx, "moderation.reason") }
|
||||
aria-label={ i18n.T(ctx, "moderation.reason") }
|
||||
class="mb-2 w-full border border-rule bg-transparent px-2 py-1 text-sm outline-none focus:border-ink"
|
||||
/>
|
||||
<button type="submit" class="border border-down px-2.5 py-1 text-down hover:bg-down hover:text-paper">{ i18n.T(ctx, "moderation.suspend") }</button>
|
||||
}
|
||||
</form>
|
||||
<button
|
||||
type="button"
|
||||
data-delete={ api }
|
||||
data-next={ next }
|
||||
data-confirm={ i18n.T(ctx, "moderation.delete_confirm_"+kind, "Name", name) }
|
||||
class="text-muted hover:text-down"
|
||||
>{ i18n.T(ctx, "moderation.delete_"+kind) }</button>
|
||||
</div>
|
||||
}
|
||||
Reference in new issue
Block a user