domain

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoTagsWhenSendErrorFormat        = "no tags for %s#%s when sending %s"
	NoUsersInTagsWhenSendErrorFormat = "tags: %v for %s#%s did not have registered users when sending %s"
)
View Source
const (
	NoUserWhenBroadcastErrorMessage      = "no users to broadcast to"
	NoMatchingTagsWhenRemoveErrorFormat  = "tag %q not found"
	NoMatchingAppsWhenRemoveErrorFormat  = "app %q not found"
	NoMatchingUsersWhenRemoveErrorFormat = "user %q not found"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID          string
	Name        string
	IconURI     string
	CommandChan chan Command
	// contains filtered or unexported fields
}

func NewApp

func NewApp(id, name, iconURI string, commandHandler CommandHandler) *App

func (*App) AddTag

func (a *App) AddTag(tag *Tag)

func (*App) GetTags

func (a *App) GetTags() []*Tag

func (*App) RemoveTag

func (a *App) RemoveTag(name string) error

func (*App) Send

func (a *App) Send(notification Notification) error

type Command

type Command struct{}

type CommandHandler

type CommandHandler interface {
	HandleCommand(command Command)
}

type Notification

type Notification struct {
	ID         string
	App        *App
	Timestamp  time.Time
	Title      string
	Subtitle   string
	Body       string
	Urgency    Urgency
	ExtURI     string
	ReadURI    string
	ArchiveURI string
}

type NotificationBroadcaster

type NotificationBroadcaster interface {
	Broadcast(notification Notification)
	RegisterClient(connection interface{})
}

type NotificationRepository

type NotificationRepository interface {
	SaveNotification(notification Notification)
	GetLastNotifications(n int) []Notification
	GetNotifications(from, to int) []Notification
	GetNotificationCount() int
}

type SendError

type SendError struct {
	*App
	Notification
	Tags []*Tag
}

func (*SendError) Error

func (e *SendError) Error() string

type Tag

type Tag struct {
	Name             string
	Users            []*User
	Apps             []*App
	NotificationChan chan Notification
	// contains filtered or unexported fields
}

func NewTag

func NewTag(name string) *Tag

type Urgency

type Urgency int
const (
	Info Urgency = iota
	Low
	Medium
	High
	Fatal
)

func (Urgency) ShortString

func (u Urgency) ShortString() string

func (Urgency) String

func (u Urgency) String() string

type User

type User struct {
	ID               string
	Username         string
	NotificationChan chan Notification
	Tags             []*Tag
	// contains filtered or unexported fields
}

func NewUser

func NewUser(id, username string, repo NotificationRepository, broadcaster NotificationBroadcaster) *User

func (*User) GetLastNotifications

func (u *User) GetLastNotifications(n int) []Notification

func (*User) GetNotificationCount

func (u *User) GetNotificationCount() int

func (*User) GetNotifications

func (u *User) GetNotifications(from int, to int) []Notification

func (*User) Receive

func (u *User) Receive(notification Notification)

func (*User) Respond

func (u *User) Respond(notification Notification, command Command)

func (*User) SubscribeToTag

func (u *User) SubscribeToTag(tag *Tag)

func (*User) UnsubscribeFromTag

func (u *User) UnsubscribeFromTag(name string) error

Jump to

Keyboard shortcuts

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