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,