 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
- func AssertSent(t *testing.T, n Notification)
- func CanMarkNotificationAsRead(s *xorm.Session, notification *DatabaseNotification, notifiableID int64) (can bool, err error)
- func Fake()
- func GetTables() []interface{}
- func MarkAllNotificationsAsRead(s *xorm.Session, userID int64) (err error)
- func MarkNotificationAsRead(s *xorm.Session, notification *DatabaseNotification, read bool) (err error)
- func Notify(notifiable Notifiable, notification Notification) (err error)
- func RenderMail(m *Mail) (mailOpts *mail.Opts, err error)
- func SendMail(m *Mail) error
- type DatabaseNotification
- func GetNotificationsForNameAndUser(s *xorm.Session, notifiableID int64, event string, subjectID int64) (notifications []*DatabaseNotification, err error)
- func GetNotificationsForUser(s *xorm.Session, notifiableID int64, limit, start int) (notifications []*DatabaseNotification, resultCount int, total int64, err error)
 
- type Mail
- type Notifiable
- type Notification
- type NotificationWithSubject
- type SubjectID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertSent ¶ added in v0.18.0
func AssertSent(t *testing.T, n Notification)
AssertSent asserts a notification has been sent
func CanMarkNotificationAsRead ¶
func CanMarkNotificationAsRead(s *xorm.Session, notification *DatabaseNotification, notifiableID int64) (can bool, err error)
CanMarkNotificationAsRead checks if a user can mark a notification as read.
func GetTables ¶
func GetTables() []interface{}
    GetTables returns all structs which are also a table.
func MarkAllNotificationsAsRead ¶ added in v0.22.0
func MarkNotificationAsRead ¶
func MarkNotificationAsRead(s *xorm.Session, notification *DatabaseNotification, read bool) (err error)
MarkNotificationAsRead marks a notification as read. It should be called only after CanMarkNotificationAsRead has been called.
func Notify ¶
func Notify(notifiable Notifiable, notification Notification) (err error)
Notify notifies a notifiable of a notification
func RenderMail ¶
RenderMail takes a precomposed mail message and renders it into a ready to send mail.Opts object
Types ¶
type DatabaseNotification ¶
type DatabaseNotification struct {
	// The unique, numeric id of this notification.
	ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"notificationid"`
	// The ID of the notifiable this notification is associated with.
	NotifiableID int64 `xorm:"bigint not null" json:"-"`
	// The actual content of the notification.
	Notification interface{} `xorm:"json not null" json:"notification"`
	// The name of the notification
	Name string `xorm:"varchar(250) index not null" json:"name"`
	// The thing the notification is about. Used to check if a notification for this thing already happened or not.
	SubjectID int64 `xorm:"bigint null" json:"-"`
	// When this notification is marked as read, this will be updated with the current timestamp.
	ReadAt time.Time `xorm:"datetime null" json:"read_at"`
	// A timestamp when this notification was created. You cannot change this value.
	Created time.Time `xorm:"created not null" json:"created"`
}
    DatabaseNotification represents a notification that was saved to the database
func GetNotificationsForNameAndUser ¶ added in v0.18.0
func GetNotificationsForUser ¶
func GetNotificationsForUser(s *xorm.Session, notifiableID int64, limit, start int) (notifications []*DatabaseNotification, resultCount int, total int64, err error)
GetNotificationsForUser returns all notifications for a user. It is possible to limit the amount of notifications to return with the limit and start parameters. We're not passing a user object in directly because every other package imports this one so we'd get import cycles.
func (*DatabaseNotification) TableName ¶
func (d *DatabaseNotification) TableName() string
TableName resolves to a better table name for notifications
type Mail ¶
type Mail struct {
	// contains filtered or unexported fields
}
    Mail is a mail message
type Notifiable ¶
type Notifiable interface {
	// RouteForMail should return the email address this notifiable has.
	RouteForMail() (string, error)
	// RouteForDB should return the id of the notifiable entity to save it in the database.
	RouteForDB() int64
	// ShouldNotify provides a last-minute way to cancel a notification. It will be called immediately before
	// sending a notification.
	ShouldNotify() (should bool, err error)
}
    Notifiable is an entity which can be notified. Usually a user.
type Notification ¶
Notification is a notification which can be sent via mail or db.
type NotificationWithSubject ¶ added in v0.18.0
type NotificationWithSubject interface {
	Notification
	SubjectID
}