notifications

package
v0.0.0-...-6dfde0d Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AFriendRequest Action = "friendrequest"
	AFriendAccept         = "friendaccept"
	AUserTag              = "usertag"
	ALike                 = "like"
	AComment              = "comment"
	AEventUpdate          = "eventupdate"
)

Variables

View Source
var (
	ErrScanAction   = errors.New("Could not scan action")
	ErrNotifySelf   = errors.New("Cannot notify yourself")
	ErrDeviceToken  = errors.New("This user does not have a valid device token")
	ErrNotifMessage = errors.New("This notification does not have a valid message")
)

Functions

func BulkNotify

func BulkNotify(userID string, b BulkNotifier, db *gorm.DB)

func CountByUserID

func CountByUserID(userID string, db *gorm.DB) (count int, err error)

Types

type Action

type Action string

func (*Action) Scan

func (a *Action) Scan(src interface{}) error

func (Action) Value

func (a Action) Value() (driver.Value, error)

type BulkNotifier

type BulkNotifier interface {
	Notifier
	GetNotifUserIDs() []string
}

type Notification

type Notification struct {
	ID         string    `json:"id" gorm:"primary_key" sql:"type:uuid;default:uuid_generate_v4()"`
	UserID     string    `json:"user_id" sql:"type:uuid"` // ID of first user
	ToID       string    `json:"to_id" sql:"type:uuid"`   // ID of second user
	RecordID   string    `json:"record_id"`
	RecordType string    `json:"record_type"`
	Action     Action    `json:"action"`
	Read       bool      `json:"read"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`

	User users.User `json:"user" sql:"-"`
}

func New

func New(userID, toID string, r Notifier) (n Notification, errs models.ValidationErrors)

func NewBulk

func NewBulk(userID string, b BulkNotifier) (ns []Notification, errs models.ValidationErrors)

func (Notification) NewPushNotification

func (n Notification) NewPushNotification(db *gorm.DB) (PushNotification, error)

func (*Notification) Validate

func (n *Notification) Validate() (errs models.ValidationErrors)

type Notifications

type Notifications []Notification

func ListByUserID

func ListByUserID(userID string, db *gorm.DB) (ns Notifications, err error)

func (*Notifications) CollectUsers

func (ns *Notifications) CollectUsers(db *gorm.DB)

func (Notifications) MarkRead

func (ns Notifications) MarkRead(db *gorm.DB) error

type Notifier

type Notifier interface {
	GetID() string
	GetAction() string
	GetNotifType() string
}

type PushNotification

type PushNotification struct {
	DeviceToken    string
	Message        string
	Action         string
	Meta           map[string]interface{}
	NotificationID string
}

func (PushNotification) Prepare

func (n PushNotification) Prepare() apns.Notification

Jump to

Keyboard shortcuts

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