From 51fee50343c62f6da900520246f77e51f68e4db5 Mon Sep 17 00:00:00 2001 From: richjohnrambo Date: Thu, 10 Sep 2026 16:01:00 +0800 Subject: [PATCH] fix im profile display name remark priority --- server/im_http.go | 5 ++++- server/im_http_test.go | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/im_http.go b/server/im_http.go index ee1b667..d662874 100644 --- a/server/im_http.go +++ b/server/im_http.go @@ -9343,7 +9343,7 @@ func blockListItemPayload(item types.BlockListItem) map[string]any { } func userProfilePayload(user *types.User, ctx *types.RelationshipContext) map[string]any { - data := userSummaryPayload(user, "") + data := userSummaryPayload(user, ctx.Remark) data["relationship"] = ctx.Relationship data["topic"] = ctx.Topic data["capabilities"] = map[string]any{ @@ -9351,6 +9351,9 @@ func userProfilePayload(user *types.User, ctx *types.RelationshipContext) map[st "can_call": imCanCall(ctx.CanSend), "can_add_friend": ctx.Relationship == types.RelationshipNone, } + if ctx.Remark != "" { + data["remark"] = ctx.Remark + } if ctx.RequestID != "" { data["request_id"] = ctx.RequestID } diff --git a/server/im_http_test.go b/server/im_http_test.go index 828d3c6..9d1fea9 100644 --- a/server/im_http_test.go +++ b/server/im_http_test.go @@ -7311,6 +7311,7 @@ func TestServeIMUserProfile(t *testing.T) { Topic: types.Uid(1).P2PName(peer), Relationship: types.RelationshipFriend, CanSend: true, + Remark: "老同事", }} store.Profiles = &testProfilesStore{} defer func() { @@ -7332,6 +7333,9 @@ func TestServeIMUserProfile(t *testing.T) { if data["relationship"] != types.RelationshipFriend || data["signature"] != "hello" || data["topic"] == "" { t.Fatalf("unexpected profile response: %#v", data) } + if data["display_name"] != "老同事" || data["remark"] != "老同事" { + t.Fatalf("profile display name should use friend remark: %#v", data) + } } func TestServeIMUserQRCodes(t *testing.T) {