Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteNotification(db database.DB, o *NotificationsQuery) error
- func RegisterNotificationHooks(e events.Handler)
- func SQLUpdater(db *database.AdminDB, i *run.Info, curversion int) error
- func UpdateNotification(db database.DB, n *Notification, o *NotificationsQuery) error
- func WriteNotification(db database.DB, n *Notification) error
- type Action
- type ActionArray
- type Notification
- type NotificationsQuery
Constants ¶
View Source
const PluginName = "notifications"
View Source
const SQLVersion = 1
Variables ¶
View Source
var ErrAccessDenied = errors.New("access_denied: You don't have necessary permissions for the given query")
View Source
var Handler = func() *chi.Mux { v1mux := chi.NewMux() v1mux.Get("/notifications", readNotifications) v1mux.Post("/notifications", writeNotification) v1mux.Patch("/notifications", updateNotification) v1mux.Delete("/notifications", deleteNotification) apiMux := chi.NewMux() apiMux.NotFound(rest.NotFoundHandler) apiMux.MethodNotAllowed(rest.NotFoundHandler) apiMux.Mount("/api", v1mux) return apiMux }()
Handler is the main API handler
Functions ¶
func DeleteNotification ¶
func DeleteNotification(db database.DB, o *NotificationsQuery) error
DeleteNotification takes a queryer for notifications
func SQLUpdater ¶
SQLUpdater is in the format expected by Heedy to update the database
func UpdateNotification ¶
func UpdateNotification(db database.DB, n *Notification, o *NotificationsQuery) error
UpdateNotification is a special version that modifies all notifications satisfying the constraints given in NotificationsQuery
func WriteNotification ¶
func WriteNotification(db database.DB, n *Notification) error
WriteNotification writes the given notification. If a notification with the given key and target exists, it updates the existing notification with the new values. The notification will only update those values that are specifically set in the new notification
Types ¶
type Action ¶
type Action struct { Title string `json:"title"` Tooltip string `json:"tooltip,omitempty"` Description string `json:"description,omitempty"` // MD description shown if type is form, or if link is not given Icon string `json:"icon,omitempty"` Href string `json:"href,omitempty"` NewWindow bool `json:"new_window,omitempty"` Dismiss bool `json:"dismiss,omitempty"` Type string `json:"type"` // The type is link by default, but can be "post/json" and "post/form-data" FormSchema map[string]interface{} `json:"form_schema,omitempty"` // For post requests }
type ActionArray ¶
type ActionArray []Action
func (*ActionArray) Scan ¶
func (aa *ActionArray) Scan(val interface{}) error
func (*ActionArray) Validate ¶ added in v0.5.0
func (aa *ActionArray) Validate() (err error)
type Notification ¶
type Notification struct { Key string `json:"key"` Timestamp float64 `json:"timestamp"` User *string `json:"user,omitempty"` App *string `json:"app,omitempty"` Object *string `json:"object,omitempty"` Type *string `json:"type"` Title *string `json:"title"` Description *string `json:"description"` Actions *ActionArray `json:"actions"` Dismissible *bool `json:"dismissible"` Seen *bool `json:"seen"` Global *bool `json:"global"` }
func ReadNotifications ¶
func ReadNotifications(db database.DB, o *NotificationsQuery) ([]Notification, error)
ReadNotifications reads the notifications associated with the given user/app/object
func (*Notification) Validate ¶ added in v0.5.0
func (n *Notification) Validate() (err error)
type NotificationsQuery ¶
type NotificationsQuery struct { User *string `json:"user,omitempty" schema:"user"` App *string `json:"app,omitempty" schema:"app"` Object *string `json:"object,omitempty" schema:"object"` Global *bool `json:"global,omitempty" schema:"global"` Seen *bool `json:"seen,omitempty" schema:"seen"` Key *string `json:"key,omitempty" schema:"key"` Dismissible *bool `json:"dismissible,omitempty" schema:"dismissible"` Type *string `json:"type,omitempty"` // Whether or not to include self when * present. For example {user="test",app="*"} // is unclear whether the user's notifications should be included or not. False by default IncludeSelf *bool `json:"include_self,omitempty" schema:"include_self"` }
Click to show internal directories.
Click to hide internal directories.