中奖消息加用户名称

This commit is contained in:
hy001 2026-05-16 06:18:31 +08:00
parent 43c44692ec
commit dbd073b97f
2 changed files with 15 additions and 0 deletions

View File

@ -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)

View File

@ -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,