Documentation
¶
Overview ¶
Package notifyhttp serves the self-scoped notification-preference REST endpoints the portal settings page calls.
It registers onto the portal's authenticated mux through a registrar hook (the datahubapi pattern) rather than owning a server of its own, and it is server-side self-scoped: the authenticated caller's email is the only key it ever reads or writes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HistoryAPI ¶
type HistoryAPI struct {
// Store reads the delivery history.
Store notification.HistoryStore
// UserEmail resolves the authenticated user's email from the request,
// returning "" when unauthenticated.
UserEmail func(*http.Request) string
// Retention is how long a resolved row survives the worker's purge,
// reported so the screen can say it shows recent activity rather than a
// complete record. Zero omits the claim.
Retention time.Duration
}
HistoryAPI serves a user's own notification history: what the platform has sent them, what is queued, and what never arrived.
It is self-scoped the same way PrefsAPI is, and by the same mechanism: the authenticated caller's address is the only recipient it ever queries. There is no recipient parameter to omit or forge -- a caller cannot express a request for someone else's rows. The cross-user view is a separate, admin-gated surface (internal/admin/notifyapi).
func (*HistoryAPI) Register ¶
func (a *HistoryAPI) Register(mux *http.ServeMux)
Register mounts the history endpoint on mux.
type HistoryItem ¶
type HistoryItem struct {
ID int64 `json:"id"`
Category string `json:"category"`
Subject string `json:"subject"`
ItemTitle string `json:"item_title,omitempty"`
Actor string `json:"actor,omitempty"`
Link string `json:"link,omitempty"`
Digest bool `json:"digest"`
Status string `json:"status"`
SentAt *time.Time `json:"sent_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
HistoryItem is one notification as its recipient sees it.
It deliberately omits the delivery error text the admin view carries: a failed send fails for reasons that belong to the platform's mail infrastructure (host names, credentials, relay refusals), and the recipient can act on none of them. Status alone tells them whether to expect an email.
type HistoryResponse ¶
type HistoryResponse struct {
Data []HistoryItem `json:"data"`
Total int `json:"total"`
Page int `json:"page"`
PerPage int `json:"per_page"`
// RetentionDays is the window this history covers. Zero means the
// deployment did not report one.
RetentionDays int `json:"retention_days"`
}
HistoryResponse is one page of the caller's own notifications.
type PrefsAPI ¶
type PrefsAPI struct {
Store notification.PrefsStore
// Settings backs the delivery_available signal. Optional: when unset the
// field stays true, so a wiring gap never tells users a working feature
// is unavailable. Only the derived boolean is exposed -- no SMTP host,
// credential, or sender value reaches this non-admin response.
Settings smtp.SettingsStore
// UserEmail resolves the authenticated user's email from the request,
// returning "" when unauthenticated.
UserEmail func(*http.Request) string
}
PrefsAPI serves the preference endpoints. The composition root supplies UserEmail to resolve the authenticated caller.
type PrefsRequest ¶
type PrefsRequest struct {
Mode *string `json:"mode,omitempty"`
CommentsEnabled *bool `json:"comments_enabled,omitempty"`
MentionsEnabled *bool `json:"mentions_enabled,omitempty"`
}
PrefsRequest is the body for updating the caller's preferences. Omitted fields are left unchanged.
type PrefsResponse ¶
type PrefsResponse struct {
Mode string `json:"mode"`
CommentsEnabled bool `json:"comments_enabled"`
MentionsEnabled bool `json:"mentions_enabled"`
// DeliveryAvailable reports whether the platform currently has an SMTP
// path that could deliver these notifications. False means stored
// preferences describe an intent nothing can act on: triggers keep
// queueing rows and those rows expire undelivered.
DeliveryAvailable bool `json:"delivery_available"`
}
PrefsResponse is the user-facing preferences shape.