Documentation
¶
Overview ¶
Package announcements fetches an optional JSON feed of in-app messages from a remote URL and caches the latest payload in memory. The backend exposes this cache via an HTTP endpoint so the frontend can display a banner. Users can disable the feature entirely at any time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Feed ¶
type Feed struct {
Messages []Message `json:"messages"`
}
Feed is the top-level feed payload.
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher periodically pulls a remote JSON feed and caches the latest active message. "Active" means within the display window defined by published_at and show_until — pre-scheduled or expired messages are skipped, so a future message never shadows an active one lower in the feed.
type Message ¶
type Message struct {
ID string `json:"id"`
PublishedAt string `json:"published_at"`
ShowUntil string `json:"show_until,omitempty"`
CTAURL string `json:"cta_url,omitempty"`
DefaultLocale string `json:"default_locale,omitempty"`
Translations map[string]MessageTranslation `json:"translations,omitempty"`
// Legacy flat fields (backward compat). Cleared after normalize().
LegacyTitle string `json:"title,omitempty"`
LegacyBody string `json:"body,omitempty"`
LegacyCTALabel string `json:"cta_label,omitempty"`
}
Message is a single announcement entry. Fields match the JSON feed schema. Content is localized via the Translations map; the frontend picks the translation matching the user's current locale, falling back to DefaultLocale or the first available entry.
Legacy flat fields (title/body/cta_label) are accepted for backward compatibility with feeds that predate the translations map. They are normalized into a synthetic single-locale entry in Translations after unmarshal; see normalize().