notification

package module
v0.0.0-...-755121c Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 17 Imported by: 2

README

QOR Notification

QOR Notification provides a way to send notifications to the users. Like order update, delivery notices.

Documentation

https://doc.getqor.com/plugins/notification.html

License

Released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminSetup

func AdminSetup(Admin *admin.Admin)

Types

type Action

type Action struct {
	Name         string
	Label        string
	Method       string
	MessageTypes []string
	Resource     *admin.Resource
	Visible      func(data *QorNotification, context *admin.Context) bool
	URL          func(data *QorNotification, context *admin.Context) string
	Handler      func(actionArgument *ActionArgument) error
	Undo         func(actionArgument *ActionArgument) error
	FlashMessage func(actionArgument *ActionArgument, succeed bool, isUndo bool) string
}

func (Action) HasMessageType

func (action Action) HasMessageType(t string) bool

func (Action) ToParam

func (action Action) ToParam() string

ToParam used to register routes for actions

type ActionArgument

type ActionArgument struct {
	Message  *QorNotification
	Context  *admin.Context
	Argument interface{}
}

type ChannelInterface

type ChannelInterface interface {
	Send(message *Message, context *core.Context) error
	GetNotifications(user common.User, results *NotificationsResult, notification *Notification, context *core.Context) error
	GetUnresolvedNotificationsCount(user common.User, notification *Notification, context *core.Context) uint
	GetNotification(user common.User, notificationID string, notification *Notification, context *core.Context) (*QorNotification, error)
}

type Config

type Config struct {
}

type Message

type Message struct {
	From        auth.User
	To          auth.User
	Title       string
	Body        string
	MessageType string
	ResolvedAt  *time.Time
}

type Notification

type Notification struct {
	Config   *Config
	Channels []ChannelInterface `sql:"-"`
	Actions  []*Action          `sql:"-"`
}

func New

func New(config *Config) *Notification

func (*Notification) Action

func (notification *Notification) Action(action *Action) error

func (*Notification) AdminSetup

func (notification *Notification) AdminSetup(Admin *admin.Admin)

func (*Notification) GetAction

func (notification *Notification) GetAction(name string) *Action

func (*Notification) GetNotification

func (notification *Notification) GetNotification(user common.User, messageID string, context *core.Context) *QorNotification

func (*Notification) GetNotifications

func (notification *Notification) GetNotifications(user common.User, context *core.Context) *NotificationsResult

func (*Notification) GetUnresolvedNotificationsCount

func (notification *Notification) GetUnresolvedNotificationsCount(user common.User, context *core.Context) uint

func (*Notification) RegisterChannel

func (notification *Notification) RegisterChannel(channel ChannelInterface)

func (*Notification) Send

func (notification *Notification) Send(message *Message, context *core.Context) error

type NotificationsResult

type NotificationsResult struct {
	Notification  *Notification
	Notifications []*QorNotification
	Resolved      []*QorNotification
}

type Plugin

type Plugin struct {
	db.DBNames
	plug.EventDispatcher
}

func (*Plugin) OnRegister

func (p *Plugin) OnRegister()

type PluginDefaultNotification

type PluginDefaultNotification struct {
	NotificationKey string
}

func (*PluginDefaultNotification) ProvideOptions

func (p *PluginDefaultNotification) ProvideOptions() []string

func (*PluginDefaultNotification) ProvidesOptions

func (p *PluginDefaultNotification) ProvidesOptions(options *plug.Options)

type QorNotification

type QorNotification struct {
	aorm.Model
	aorm.Timestamps
	From        bid.BID
	To          bid.BID
	Title       string
	Body        string `sql:"size:65532"`
	MessageType string
	ResolvedAt  *time.Time
}

func (*QorNotification) Actions

func (qorNotification *QorNotification) Actions(context *admin.Context) (actions []*Action)

func (QorNotification) IsResolved

func (qorNotification QorNotification) IsResolved() bool

Directories

Path Synopsis
channels

Jump to

Keyboard shortcuts

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