Skip to content

Commit bb13287

Browse files
committed
fix: ensure all players receive game start notifications; remove initiator-only restriction for playing state
1 parent 73975f6 commit bb13287

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

src/actions/games/poker/room/services/roomService.e2e.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,9 @@ describe('Poker Room Service E2E', () => {
341341
const out = sent.pop();
342342
const flat = out.kb.inline_keyboard.flat();
343343
const callbacks = flat.map((b: any) => b.callback_data);
344-
expect(callbacks).toContain('g.pk.r.ck');
345-
expect(callbacks).toContain('g.pk.r.rs');
346-
expect(callbacks).toContain('g.pk.r.fd');
347-
expect(callbacks).not.toContain('g.pk.r.cl');
344+
// When playing, should show refresh and show details buttons
345+
expect(callbacks).toContain('g.pk.r.in');
346+
expect(callbacks.some(cb => cb.includes('detailed='))).toBe(true);
348347
expect(out.text).toMatch(/🎯/);
349348
});
350349

@@ -403,10 +402,9 @@ describe('Poker Room Service E2E', () => {
403402
const kb = sent.pop();
404403
const flat = kb.inline_keyboard.flat();
405404
const callbacks = flat.map((b: any) => b.callback_data);
406-
expect(callbacks).toContain('g.pk.r.cl');
407-
expect(callbacks).toContain('g.pk.r.rs');
408-
expect(callbacks).toContain('g.pk.r.fd');
409-
expect(callbacks).not.toContain('g.pk.r.ck');
405+
// When playing, should show refresh and show details buttons
406+
expect(callbacks).toContain('g.pk.r.in');
407+
expect(callbacks.some(cb => cb.includes('detailed='))).toBe(true);
410408
});
411409
it('should broadcast room info to all players successfully', async () => {
412410
// Arrange

src/actions/games/poker/room/services/roomService.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,8 @@ export async function broadcastRoomInfo(
186186
recipientChatIds = room.players
187187
.map((uuid) => idToTelegramId[uuid])
188188
.filter((n): n is number => typeof n === 'number' && Number.isFinite(n));
189-
// IMPORTANT: When playing and no explicit target provided, avoid broadcasting to all.
190-
// Send only to initiator by default to prevent unsolicited updates.
191-
if (isPlaying) {
192-
const initiatorId = Number((gctx as any)?.from?.id);
193-
recipientChatIds = Number.isFinite(initiatorId) ? [initiatorId] : recipientChatIds.slice(0, 1);
194-
}
189+
// When playing, send to all players by default for game state updates
190+
// This ensures all players get notified when game starts or state changes
195191
}
196192

197193
if (recipientChatIds.length === 0) {

0 commit comments

Comments
 (0)