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:
@@ -401,6 +401,23 @@ func (c *Client) CreateUser(username, email string) (*User, error) {
|
||||
return &user, c.do(req, &user)
|
||||
}
|
||||
|
||||
// SetUserNotifyTarget points a user's push notifications at an ntfy topic.
|
||||
//
|
||||
// An empty topic clears it: the server stores NULL, and that user's incidents
|
||||
// page the shared fallback topic instead — which carries no Acknowledge button,
|
||||
// because anyone subscribed to it could otherwise acknowledge as somebody else.
|
||||
func (c *Client) SetUserNotifyTarget(userID int64, topic string) (*User, error) {
|
||||
body := struct {
|
||||
NtfyTopic string `json:"ntfy_topic"`
|
||||
}{NtfyTopic: topic}
|
||||
req, err := c.newRequestWithBody(http.MethodPut, fmt.Sprintf("/api/users/%d/notify", userID), body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var user User
|
||||
return &user, c.do(req, &user)
|
||||
}
|
||||
|
||||
func (c *Client) DeleteUser(id int64) error {
|
||||
req, err := c.newRequest(http.MethodDelete, fmt.Sprintf("/api/users/%d", id))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user