Documentation
¶
Overview ¶
Package preferences holds the wire shape + validation + row-mapper for the notification_preferences collection.
This package is intentionally separate from internal/router/ because the router is a pure function operating on a resolved Preferences struct, while this package owns the persistence + JSON marshalling boilerplate. Keeping them apart preserves the router's no-dependencies-but-time discipline.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyWire ¶
ApplyWire writes the Wire fields into the *core.Record. user_id / tenant are forced by the caller so this only writes the mutable columns.
func ToRouterPreferences ¶
func ToRouterPreferences(w Wire) *router.Preferences
ToRouterPreferences converts a Wire into the router's Preferences struct. Caller of router.DeliveryChannels uses this to bridge the persistence and routing layers.
Types ¶
type Wire ¶
type Wire struct {
ID string `json:"id,omitempty"`
UserID string `json:"user_id"`
OrgID string `json:"org_id"`
PrimaryEmail string `json:"primary_email"`
BackupEmail string `json:"backup_email,omitempty"`
PrimaryPhone string `json:"primary_phone,omitempty"`
WhatsAppPhone string `json:"whatsapp_phone,omitempty"`
LegalEmail string `json:"legal_email"`
PreferredChannels []string `json:"preferred_channels"`
RealtimeChannels []string `json:"realtime_channels"`
MarketingSubscriptions map[string]bool `json:"marketing_subscriptions"`
QuietHoursStart string `json:"quiet_hours_start"`
QuietHoursEnd string `json:"quiet_hours_end"`
Timezone string `json:"timezone"`
MarketingGloballyMuted bool `json:"marketing_globally_muted"`
Created string `json:"created,omitempty"`
Updated string `json:"updated,omitempty"`
}
Wire is the JSON shape returned by GET /v1/notify/preferences and accepted by PUT /v1/notify/preferences. Field order + names match §2.1 of the notification-preferences paper.