preference

package
v1.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package preference defines user notification preference entities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelPreference

type ChannelPreference struct {
	Email *bool `json:"email,omitempty"`
	SMS   *bool `json:"sms,omitempty"`
	Push  *bool `json:"push,omitempty"`
	InApp *bool `json:"inapp,omitempty"`
}

ChannelPreference holds per-channel opt-in/opt-out settings. nil means "use default" (opted-in).

type Preference

type Preference struct {
	ID        id.PreferenceID              `json:"id"`
	AppID     string                       `json:"app_id"`
	UserID    string                       `json:"user_id"`
	Overrides map[string]ChannelPreference `json:"overrides"`
	CreatedAt time.Time                    `json:"created_at"`
	UpdatedAt time.Time                    `json:"updated_at"`
}

Preference represents a user's notification preferences for an app. Overrides is keyed by notification type slug (e.g., "auth.welcome").

func (*Preference) IsOptedOut

func (p *Preference) IsOptedOut(notifType, channel string) bool

IsOptedOut checks whether the user has explicitly opted out of a specific notification type on a specific channel. Returns false (not opted out) if no preference is set.

type Store

type Store interface {
	GetPreference(ctx context.Context, appID string, userID string) (*Preference, error)
	SetPreference(ctx context.Context, p *Preference) error
	DeletePreference(ctx context.Context, appID string, userID string) error
}

Store defines persistence operations for user notification preferences.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL