fix: 统一用户资料投影并放开头像访问
This commit is contained in:
@@ -3109,6 +3109,14 @@ func serveIMMeProfile(wrt http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if body.AvatarFileID != nil {
|
||||
if avatar := strings.TrimSpace(*body.AvatarFileID); avatar != "" {
|
||||
if err := store.Files.LinkAttachments(principal.TenantID, principal.Uid.UserId(), types.ZeroUid, []string{avatar}); err != nil {
|
||||
writeIMRelationError(wrt, req, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
profile, err := store.Profiles.Update(principal.TenantID, principal.Uid, types.UserProfilePatch{
|
||||
AvatarFileID: body.AvatarFileID,
|
||||
Nickname: body.Nickname,
|
||||
@@ -4603,6 +4611,11 @@ func serveIMGroupCreate(wrt http.ResponseWriter, req *http.Request) {
|
||||
writeIMRelationError(wrt, req, err)
|
||||
return
|
||||
}
|
||||
if settings.AvatarFileID != "" {
|
||||
if err := store.Files.LinkAttachments(principal.TenantID, topicName, types.ZeroUid, []string{settings.AvatarFileID}); err != nil {
|
||||
logs.Warn.Printf("group[%s]: failed to link avatar attachment: %v", topicName, err)
|
||||
}
|
||||
}
|
||||
dispatchIMGroupEvents(principal.TenantID)
|
||||
created, err := store.Topics.Get(principal.TenantID, topicName)
|
||||
if err != nil {
|
||||
@@ -4897,6 +4910,13 @@ func serveIMGroupDetail(wrt http.ResponseWriter, req *http.Request, topic string
|
||||
return
|
||||
}
|
||||
}
|
||||
if body.AvatarFileID != nil {
|
||||
if avatar := strings.TrimSpace(*body.AvatarFileID); avatar != "" {
|
||||
if err := store.Files.LinkAttachments(principal.TenantID, topic, types.ZeroUid, []string{avatar}); err != nil {
|
||||
logs.Warn.Printf("group[%s]: failed to link avatar attachment: %v", topic, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
dispatchIMGroupEvents(principal.TenantID)
|
||||
updated, err := store.Topics.Get(principal.TenantID, topic)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user