Fix bootstrap meeting unread counts
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user