Fix bootstrap meeting unread counts

This commit is contained in:
richjohnrambo
2026-09-05 18:31:13 +08:00
parent baf15848d3
commit 7a1647bf17
7 changed files with 96 additions and 4 deletions
+24
View File
@@ -1711,6 +1711,10 @@ func serveIMBootstrap(wrt http.ResponseWriter, req *http.Request) {
}
}
modulePayloads := workbenchModulePayloads(modules)
if err := populateWorkbenchModuleUnreadCounts(principal.TenantID, principal.Uid, modulePayloads); err != nil {
writeIMRelationError(wrt, req, err)
return
}
entryBadges, entries, err := bootstrapEntryPayloads(principal.TenantID, principal.Uid, modulePayloads)
if err != nil {
writeIMRelationError(wrt, req, err)
@@ -7855,6 +7859,26 @@ func workbenchModulePayloads(modules []types.WorkbenchModule) []map[string]any {
return items
}
func populateWorkbenchModuleUnreadCounts(tenantID types.TenantID, uid types.Uid, modules []map[string]any) error {
if store.Security == nil {
return nil
}
for _, module := range modules {
code, _ := module["code"].(string)
switch code {
case "meetings":
count, err := store.Security.CountUnreadSystemNotificationsByEventPrefix(tenantID, uid, "meeting.")
if err != nil && !errors.Is(err, types.ErrNotFound) && !errors.Is(err, types.ErrUnsupported) {
return err
}
if err == nil {
module["unread_count"] = count
}
}
}
return nil
}
func bootstrapEntryPayloads(tenantID types.TenantID, uid types.Uid, modules []map[string]any) (map[string]any, map[string]any, error) {
newFriendsPending := 0
if store.Relations != nil {