feat: ntfy topics per user, and notifications on the timeline
Release / test (push) Failing after 6s
Release / release (push) Has been skipped
Release / build (amd64, darwin) (push) Has been skipped
Release / build (amd64, linux) (push) Has been skipped
Release / build (arm64, darwin) (push) Has been skipped
Release / build (arm64, linux) (push) Has been skipped
Release / test (push) Failing after 6s
Release / release (push) Has been skipped
Release / build (amd64, darwin) (push) Has been skipped
Release / build (amd64, linux) (push) Has been skipped
Release / build (arm64, darwin) (push) Has been skipped
Release / build (arm64, linux) (push) Has been skipped
terdut-server pages the on-call person through ntfy, but none of it was reachable from here. A user's topic could only be set with curl, so a new user silently got no pages and quietly fell back to the shared fallback topic — which carries no Acknowledge button. And nothing said whether anybody had been paged at all. The Users section grows an Ntfy Topic column and t to edit it, prefilled with the current value. Submitting an empty field clears the topic rather than being rejected as a mistake: clearing is how somebody is taken off their own topic, and it is what the server means by an empty string. Nil and empty arrive as the same thing, because the server stores a blank topic as NULL, so User.Topic flattens the two instead of leaving every caller to. The incident timeline renders the server's notified and notify_failed events. No new fetch — the timeline endpoint already carried them, and unknown types already fell through to a generic label; this is about saying something useful. An event with no user means the fallback topic, not "the server acted", which is the difference between somebody having been paged and the rota having been empty. Both need terdut-server v0.6.0 or later, and the timeline entries a server newer than that. Against an older one the column stays empty and editing a topic reports the server's 404, which is the honest answer.
This commit is contained in:
@@ -95,6 +95,13 @@ const (
|
||||
EventUnsnoozed = "unsnoozed"
|
||||
EventResolved = "resolved"
|
||||
EventNote = "note"
|
||||
|
||||
// Written by the server's notifier from the delivery result, not at enqueue.
|
||||
// Detail carries the notification kind ("triggered", "reminder", "resolved"),
|
||||
// and on a failure the reason after it. An absent user means the page went to
|
||||
// the shared fallback topic rather than to a person.
|
||||
EventNotified = "notified"
|
||||
EventNotifyFailed = "notify_failed"
|
||||
)
|
||||
|
||||
// IncidentEvent is one entry in an incident's timeline. An empty Username means
|
||||
@@ -158,6 +165,21 @@ type User struct {
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
|
||||
// NtfyTopic is where this user's push notifications go. Nil and empty mean
|
||||
// the same thing — no topic of their own — because the server stores a blank
|
||||
// string as NULL. Their incidents fall back to the server's shared fallback
|
||||
// topic, which carries no Acknowledge button.
|
||||
NtfyTopic *string `json:"ntfy_topic,omitempty"`
|
||||
}
|
||||
|
||||
// Topic reads the user's ntfy topic, flattening the nil and empty cases the
|
||||
// server treats alike.
|
||||
func (u User) Topic() string {
|
||||
if u.NtfyTopic == nil {
|
||||
return ""
|
||||
}
|
||||
return *u.NtfyTopic
|
||||
}
|
||||
|
||||
type APIKey struct {
|
||||
|
||||
Reference in New Issue
Block a user