fix: return saved group nickname profile

This commit is contained in:
richjohnrambo
2026-09-03 10:01:24 +08:00
parent 8193491686
commit 1eee0179f1
2 changed files with 52 additions and 6 deletions
+14 -6
View File
@@ -4688,7 +4688,7 @@ func serveIMGroupMemberSettings(wrt http.ResponseWriter, req *http.Request, topi
}
func serveIMGroupMyProfile(wrt http.ResponseWriter, req *http.Request, topic string) {
if req.Method != http.MethodPut {
if req.Method != http.MethodPut && req.Method != http.MethodGet {
writeIMError(wrt, req, http.StatusMethodNotAllowed, 30002, imReasonMethodNotAllowed, "method not allowed", nil)
return
}
@@ -4696,6 +4696,19 @@ func serveIMGroupMyProfile(wrt http.ResponseWriter, req *http.Request, topic str
if !ok {
return
}
private := groupPrivateMap(selfSub.Private)
currentVersion := intFromAny(private["profile_version"])
if currentVersion <= 0 {
currentVersion = 1
}
if req.Method == http.MethodGet {
writeIMSuccess(wrt, req, map[string]any{
"nickname": stringFromAny(private["nickname"]),
"version": currentVersion,
"updated_at": stringFromAny(private["profile_updated_at"]),
})
return
}
var body imGroupMemberProfileUpdateRequest
if !decodeIMJSONBody(wrt, req, &body) {
return
@@ -4705,11 +4718,6 @@ func serveIMGroupMyProfile(wrt http.ResponseWriter, req *http.Request, topic str
writeIMError(wrt, req, http.StatusBadRequest, 30000, imReasonMalformedRequest, "malformed request", map[string]any{"field": "nickname"})
return
}
private := groupPrivateMap(selfSub.Private)
currentVersion := intFromAny(private["profile_version"])
if currentVersion <= 0 {
currentVersion = 1
}
if body.Version > 0 && body.Version != currentVersion {
writeIMError(wrt, req, http.StatusConflict, 30006, "VERSION_CONFLICT", "version conflict", map[string]any{"current_version": currentVersion})
return