fix: keep group avatar update for legacy groups

This commit is contained in:
richjohnrambo
2026-09-03 14:25:10 +08:00
parent a0bd0b0649
commit db00e994d5
2 changed files with 107 additions and 17 deletions
+14 -6
View File
@@ -4680,12 +4680,18 @@ func serveIMGroupDetail(wrt http.ResponseWriter, req *http.Request, topic string
return
}
patch := types.GroupSettingsPatch{Name: body.Name, AvatarFileID: body.AvatarFileID, Description: body.Description, Version: body.Version}
settingsUpdated := true
if _, err = store.GroupBusiness.UpdateSettings(principal.TenantID, topic, patch); err != nil {
if rollbackErr := store.Topics.Update(principal.TenantID, topic, map[string]any{"Public": group.Public}); rollbackErr != nil {
logs.Warn.Printf("group[%s]: failed to roll back topic profile after business update error: %v", topic, rollbackErr)
if errors.Is(err, types.ErrNotFound) {
settingsUpdated = false
logs.Warn.Printf("group[%s]: business settings missing while patching group profile; kept topic public update", topic)
} else {
if rollbackErr := store.Topics.Update(principal.TenantID, topic, map[string]any{"Public": group.Public}); rollbackErr != nil {
logs.Warn.Printf("group[%s]: failed to roll back topic profile after business update error: %v", topic, rollbackErr)
}
writeIMRelationError(wrt, req, err)
return
}
writeIMRelationError(wrt, req, err)
return
}
dispatchIMGroupEvents(principal.TenantID)
updated, err := store.Topics.Get(principal.TenantID, topic)
@@ -4694,8 +4700,10 @@ func serveIMGroupDetail(wrt http.ResponseWriter, req *http.Request, topic string
return
}
payload := groupDetailPayload(updated, selfSub)
if settings, err := store.GroupBusiness.GetSettings(principal.TenantID, topic); err == nil {
payload = mergeGroupSettingsPayload(payload, settings)
if settingsUpdated {
if settings, err := store.GroupBusiness.GetSettings(principal.TenantID, topic); err == nil {
payload = mergeGroupSettingsPayload(payload, settings)
}
}
writeIMSuccess(wrt, req, payload)
default: