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 catalogapi 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
// Inbox is the read state of the caller's rows (#2512): an unread count
// and list that work with no mail server. nil reports every row read and
// leaves the read routes unregistered.
Inbox notification.InboxStore
// Retention is how long the Inbox keeps a notification (#2906),
// reported so the screen can say how far back it reaches. 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) MentionSource ¶ added in v1.175.0
func (a *HistoryAPI) MentionSource() waiting.Source
MentionSource is the unread mentions of the caller for the Inbox's Waiting on you (#2907): each stays there until it is read, which replying or marking it read from the Inbox does.
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"`
Kind string `json:"kind"`
// Subject is the kind's sentence, the line the email's subject carries.
Subject string `json:"subject"`
// ItemID is the item or thread the notification is about (#2907): a
// mention's thread, which a reply from the Inbox is posted to.
ItemID string `json:"item_id,omitempty"`
ItemTitle string `json:"item_title,omitempty"`
Actor string `json:"actor,omitempty"`
// Persona names the persona a share was addressed to, when the caller
// was told of it as one of its members.
Persona string `json:"persona,omitempty"`
// Excerpt is the message the email quotes, or the start of what it says.
Excerpt string `json:"excerpt,omitempty"`
Link string `json:"link,omitempty"`
// ReceivedAt is when the notification reached the Inbox.
ReceivedAt time.Time `json:"received_at"`
// Unread reports a row the caller has not read in the portal (#2512).
Unread bool `json:"unread"`
}
HistoryItem is one notification as its recipient sees it in their Inbox (#2906): the kind's sentence, the actor, the item, and the excerpt the email carries.
It deliberately carries no delivery state: whether, and when, an email was sent is the administrators' delivery history. A notification reaches the Inbox whatever the person chose for email and whether or not a mail server is configured.
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 MarkReadRequest ¶ added in v1.153.2
type MarkReadRequest struct {
IDs []int64 `json:"ids"`
// ItemID marks the rows about one item read: the asset, collection or
// other shared item, or the thread, a notification is about. The portal
// sends it when the person opens one (#2906).
ItemID string `json:"item_id,omitempty"`
}
MarkReadRequest names the rows to mark read: by id, or every row about one item; neither marks every row.
type MarkReadResponse ¶ added in v1.153.2
type MarkReadResponse struct {
Marked int64 `json:"marked"`
}
MarkReadResponse is how many rows changed.
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
// InboxRetention is how long the Inbox keeps a notification, said on
// the settings page.
InboxRetention time.Duration
}
PrefsAPI serves the preference endpoints. The composition root supplies UserEmail to resolve the authenticated caller.
type PrefsRequest ¶
type PrefsRequest struct {
// Categories maps a category to immediate, daily or off.
Categories map[string]string `json:"categories"`
}
PrefsRequest is the body for updating the caller's preferences. A category it does not name is left unchanged.
type PrefsResponse ¶
type PrefsResponse struct {
// Categories maps each category a person chooses email for to
// immediate, daily or off (#2906). Account is not among them: it is
// always emailed.
Categories map[string]string `json:"categories"`
// DeliveryAvailable reports whether the platform currently has an SMTP
// path that could deliver these notifications. False means nothing is
// emailed, and every notification still reaches the Inbox.
DeliveryAvailable bool `json:"delivery_available"`
// InboxRetentionDays is how long the Inbox keeps a notification,
// whatever is emailed.
InboxRetentionDays int `json:"inbox_retention_days"`
}
PrefsResponse is the user-facing preferences shape.
type UnreadCountResponse ¶ added in v1.153.2
type UnreadCountResponse struct {
Unread int `json:"unread"`
}
UnreadCountResponse is how many of the caller's notifications are unread.