Documentation
¶
Index ¶
- Variables
- type Clock
- type EmailSender
- type Notification
- type NotifyInput
- type NotifyService
- func (s *NotifyService) Archive(ctx context.Context, userID, id string) error
- func (s *NotifyService) Badge(ctx context.Context, userID, workspaceID string) (int, error)
- func (s *NotifyService) Inbox(ctx context.Context, userID, workspaceID string, limit int) ([]Notification, error)
- func (s *NotifyService) ListPreferences(ctx context.Context, userID string) ([]Preference, error)
- func (s *NotifyService) MarkAllRead(ctx context.Context, userID string) error
- func (s *NotifyService) MarkRead(ctx context.Context, userID, id string) error
- func (s *NotifyService) Notify(ctx context.Context, input NotifyInput) error
- func (s *NotifyService) NotifyOncePerMonth(ctx context.Context, input NotifyInput) error
- func (s *NotifyService) SendEmail(ctx context.Context, to, subject, body string) error
- func (s *NotifyService) SendTypeEmail(ctx context.Context, userID, typ, to, subject, body string) error
- func (s *NotifyService) UpsertPreference(ctx context.Context, userID, typ string, email, inApp *bool) (Preference, error)
- func (s *NotifyService) WithPrefGate(gate PrefGate) *NotifyService
- type PrefGate
- type Preference
- type Repo
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type EmailSender ¶
type Notification ¶
type Notification struct {
ID string `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
Body string `json:"body"`
Link string `json:"link,omitempty"`
Workspace string `json:"workspace_id,omitempty"`
Count int `json:"count"`
ReadAt *time.Time `json:"read_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
type NotifyInput ¶
type NotifyInput struct {
UserID string
Type string
Title string
Body string
Link string
// Workspace is the optional workspace dimension (F8): empty = user-global
// notification (the framework bell model); set = the notification belongs to
// that workspace's scoped inbox. Note dedup: uq_notification_dedup keys on
// (user_id, dedup_key) — per-workspace dedup requires the workspace id inside
// the DedupKey itself.
Workspace string
DedupKey string
OncePerMonth bool
}
type NotifyService ¶
type NotifyService struct {
// contains filtered or unexported fields
}
func NewNotifyService ¶
func NewNotifyService(repo Repo, mail EmailSender, now Clock) *NotifyService
func (*NotifyService) Archive ¶
func (s *NotifyService) Archive(ctx context.Context, userID, id string) error
func (*NotifyService) Inbox ¶
func (s *NotifyService) Inbox(ctx context.Context, userID, workspaceID string, limit int) ([]Notification, error)
func (*NotifyService) ListPreferences ¶
func (s *NotifyService) ListPreferences(ctx context.Context, userID string) ([]Preference, error)
func (*NotifyService) MarkAllRead ¶
func (s *NotifyService) MarkAllRead(ctx context.Context, userID string) error
func (*NotifyService) MarkRead ¶
func (s *NotifyService) MarkRead(ctx context.Context, userID, id string) error
func (*NotifyService) Notify ¶
func (s *NotifyService) Notify(ctx context.Context, input NotifyInput) error
func (*NotifyService) NotifyOncePerMonth ¶
func (s *NotifyService) NotifyOncePerMonth(ctx context.Context, input NotifyInput) error
func (*NotifyService) SendEmail ¶
func (s *NotifyService) SendEmail(ctx context.Context, to, subject, body string) error
func (*NotifyService) SendTypeEmail ¶
func (s *NotifyService) SendTypeEmail(ctx context.Context, userID, typ, to, subject, body string) error
func (*NotifyService) UpsertPreference ¶
func (s *NotifyService) UpsertPreference(ctx context.Context, userID, typ string, email, inApp *bool) (Preference, error)
func (*NotifyService) WithPrefGate ¶
func (s *NotifyService) WithPrefGate(gate PrefGate) *NotifyService
type PrefGate ¶
type PrefGate interface {
List(ctx context.Context, userID string) ([]Preference, error)
Upsert(ctx context.Context, userID, typ string, email, inApp *bool) (Preference, error)
Allowed(ctx context.Context, userID, typ string) (bool, error)
EmailAllowed(ctx context.Context, userID, typ string) (bool, error)
}
type Preference ¶
type Repo ¶
type Repo interface {
Insert(ctx context.Context, n NotifyInput, now time.Time) (isNew bool, err error)
// ListInbox / UnreadCount take an optional workspaceID filter: empty lists the
// whole user inbox (bell semantics), non-empty restricts to that workspace.
ListInbox(ctx context.Context, userID, workspaceID string, limit int) ([]Notification, error)
UnreadCount(ctx context.Context, userID, workspaceID string) (int, error)
MarkRead(ctx context.Context, userID, notificationID string) error
MarkAllRead(ctx context.Context, userID string) error
Archive(ctx context.Context, userID, notificationID string) error
}
Click to show internal directories.
Click to hide internal directories.