fix: notifier groups cache not initialized (#995)

This commit is contained in:
UUBulb 2025-02-17 20:14:38 +08:00 committed by GitHub
parent 65f9db7d5a
commit 029d6dbd5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -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")
}
}

View File

@ -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]