notification

package
v0.0.0-...-8495beb Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notification

type Notification struct {
	ID           NotificationID `json:"id"`
	Title        string         `json:"title"`
	Description  string         `json:"description"`
	Link         string         `json:"link"`
	Read         bool           `json:"read"`
	CreatedAt    time.Time      `json:"createdAt"`
	Subscription Subscription   `json:"subscription"`
}

func FromModel

func FromModel(m *model.Notification) *Notification

func FromModelMany

func FromModelMany(m []*model.Notification) []Notification

type NotificationID

type NotificationID xid.ID

type NotificationType

type NotificationType string

type Repository

type Repository interface {
	Subscribe(ctx context.Context, userID account.AccountID, refersType NotificationType, refersTo string) (*Subscription, error)
	Unsubscribe(ctx context.Context, userID account.AccountID, subID SubscriptionID) (int, error)

	GetSubscriptionsForUser(ctx context.Context, userID account.AccountID) ([]Subscription, error)
	GetSubscriptionsForItem(ctx context.Context, refersType NotificationType, refersTo string) ([]Subscription, error)
	GetNotifications(ctx context.Context, userID account.AccountID, read bool, after time.Time) ([]Notification, error)

	Notify(ctx context.Context, refersType NotificationType, refersTo string, title, desc, link string) (int, error)
	SetReadState(ctx context.Context, userID account.AccountID, notificationID NotificationID, read bool) (*Notification, error)
	Delete(ctx context.Context, userID account.AccountID, notificationID NotificationID) (*Notification, error)
}

func New

func New(db *model.Client) Repository

type Subscription

type Subscription struct {
	ID         SubscriptionID   `json:"id"`
	RefersType NotificationType `json:"refersType"`
	RefersTo   string           `json:"refersTo"`
	CreatedAt  time.Time        `json:"createdAt"`
}

func SubFromModel

func SubFromModel(m *model.Subscription) *Subscription

func SubFromModelMany

func SubFromModelMany(m []*model.Subscription) []Subscription

type SubscriptionID

type SubscriptionID xid.ID

Jump to

Keyboard shortcuts

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