QOR Notification

QOR Notification provides a way to send notifications to QOR Admin administrators. Notifications can be anything your system needs, like order update, delivery notices, whatever.


Notification := notification.New(&notification.Config{})

// Add to Admin

// Register Database Channel
Notification.RegisterChannel(database.New(&database.Config{DB: db.DB}))

// Send Notification
Notification.Send(message *Message, context *qor.Context)

// Get Notification
Notification.GetNotification(user interface{}, messageID string, context *qor.Context)

// Get Notifications
Notification.GetNotifications(user interface{}, context *qor.Context)

// Get Unresolved Notifications Count
Notification.GetUnresolvedNotificationsCount(user interface{}, context *qor.Context)

The Notifications List in QOR Admin looks a bit like this when populated:


Register Actions for Notification

This example shows how to add a "Dismiss" button to notification. The button will appears in the notification which ResolvedAt is nil. Please read the Action documentation for more details.

        Name:         "Dismiss",
        MessageTypes: []string{"info", "order_processed", "order_returned"},
        Visible: func(data *notification.QorNotification, context *admin.Context) bool {
                return data.ResolvedAt == nil
        Handle: func(argument *notification.ActionArgument) error {
                return argument.Context.GetDB().Model(argument.Message).Update("resolved_at", time.Now()).Error

results matching ""

    No results matching ""