Skip to content

Commit

Permalink
fix: notifier groups cache not initialized (#995)
Browse files Browse the repository at this point in the history
  • Loading branch information
uubulb authored Feb 17, 2025
1 parent 65f9db7 commit 029d6db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/dashboard/controller/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func batchDeleteNotification(c *gin.Context) (any, error) {
for _, nid := range n {
if ns, ok := singleton.NotificationMap[nid]; ok {
if !ns.HasPermission(c) {
singleton.NotificationsLock.RUnlock()
return nil, singleton.Localizer.ErrorT("permission denied")
}
}
Expand Down
6 changes: 6 additions & 0 deletions service/singleton/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func loadNotifications() {
panic(err)
}

var groups []model.NotificationGroup
DB.Find(&groups)
for _, grp := range groups {
NotificationGroup[grp.ID] = grp.Name
}

NotificationMap = make(map[uint64]*model.Notification, len(NotificationListSorted))
for i := range NotificationListSorted {
NotificationMap[NotificationListSorted[i].ID] = NotificationListSorted[i]
Expand Down

0 comments on commit 029d6db

Please sign in to comment.