From dbd073b97fe31b4df7010c68ed820454505779d6 Mon Sep 17 00:00:00 2001 From: hy001 Date: Sat, 16 May 2026 06:18:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AD=E5=A5=96=E6=B6=88=E6=81=AF=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/voiceroomrocket/event_test.go | 11 +++++++++++ internal/service/voiceroomrocket/notify.go | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/internal/service/voiceroomrocket/event_test.go b/internal/service/voiceroomrocket/event_test.go index 39917b1..ee24c84 100644 --- a/internal/service/voiceroomrocket/event_test.go +++ b/internal/service/voiceroomrocket/event_test.go @@ -641,6 +641,14 @@ func TestNotifyLaunchPublishesIMAndRedisStream(t *testing.T) { func TestNotifyRewardRecordPublishesIMAndRedisStream(t *testing.T) { gateway := newFakeRocketGateway() + gateway.profiles = map[int64]integration.UserProfile{ + 1001: { + ID: integration.Int64Value(1001), + Account: "223456", + UserAvatar: "https://cdn.example.com/avatar-1001.png", + UserNickname: "Winner", + }, + } service, _, rdb, mr := newTestServiceWithRedis(t, gateway) defer mr.Close() fakeIM := &fakeRocketIM{} @@ -677,6 +685,9 @@ func TestNotifyRewardRecordPublishesIMAndRedisStream(t *testing.T) { if data["userId"] != "1001" || data["rewardRecordId"] != "9901" { t.Fatalf("im data = %#v", data) } + if data["userNickname"] != "Winner" || data["account"] != "223456" || data["userAvatar"] != "https://cdn.example.com/avatar-1001.png" { + t.Fatalf("im user profile = %#v", data) + } count, err := rdb.XLen(context.Background(), "voice_room:rocket:broadcast").Result() if err != nil { t.Fatalf("xlen broadcast: %v", err) diff --git a/internal/service/voiceroomrocket/notify.go b/internal/service/voiceroomrocket/notify.go index 275bb35..51d7cdd 100644 --- a/internal/service/voiceroomrocket/notify.go +++ b/internal/service/voiceroomrocket/notify.go @@ -211,6 +211,7 @@ func (s *Service) notifyRewardRecords(ctx context.Context, launch model.VoiceRoo } func (s *Service) notifyRewardRecord(ctx context.Context, record model.VoiceRoomRocketRewardRecord) error { + profile := s.mapUserProfiles(ctx, []int64{record.UserID})[record.UserID] body := map[string]any{ "type": imTypeRewardUser, "data": map[string]any{ @@ -218,6 +219,9 @@ func (s *Service) notifyRewardRecord(ctx context.Context, record model.VoiceRoom "launchNo": record.LaunchNo, "level": record.Level, "userId": strconv.FormatInt(record.UserID, 10), + "userAvatar": profile.UserAvatar, + "userNickname": profile.UserNickname, + "account": profile.Account, "rewardScene": record.RewardScene, "rewardType": record.RewardType, "rewardName": record.RewardName,