Admin notify one user

This commit is contained in:
2024-07-03 23:07:59 +08:00
parent 74819c1c2b
commit 182a389180
5 changed files with 72 additions and 8 deletions

View File

@ -31,7 +31,7 @@ func AddAuditRecord(operator models.Account, act, ip, ua string, metadata map[st
})
}
// SaveEventChanges runs every 60 seconds to save events / audits changes into database
// SaveEventChanges runs every 60 seconds to save events / audits changes into the database
func SaveEventChanges() {
if len(writeEventQueue) > 0 {
count := len(writeEventQueue)

View File

@ -42,6 +42,7 @@ func AddNotifySubscriber(user models.Account, provider, id, tk, ua string) (mode
return subscriber, err
}
// NewNotification will create a notification and push via the push method it
func NewNotification(notification models.Notification) error {
if err := database.C.Save(&notification).Error; err != nil {
return err
@ -54,6 +55,9 @@ func NewNotification(notification models.Notification) error {
return nil
}
// PushNotification will push the notification what ever it is exists record in the database
// Recommend push another goroutine when you need to push a lot of notification
// And just use block statement when you just push one notification, the time of create a new sub-process is much more than push notification
func PushNotification(notification models.Notification) error {
for conn := range wsConn[notification.RecipientID] {
_ = conn.WriteMessage(1, models.UnifiedCommand{
@ -62,7 +66,7 @@ func PushNotification(notification models.Notification) error {
}.Marshal())
}
// Skip push notify
// Skip push notification
if GetStatusDisturbable(notification.RecipientID) != nil {
return nil
}