diff --git a/src/backend/services/socket/SocketService.test.ts b/src/backend/services/socket/SocketService.test.ts index 127e6b9dd..a8172d928 100644 --- a/src/backend/services/socket/SocketService.test.ts +++ b/src/backend/services/socket/SocketService.test.ts @@ -625,6 +625,24 @@ describe('SocketService (live socket.io)', () => { await closeAll(userId, [other]); }); + it('joins only the ack room of the room it is asked in', async () => { + const userId = await userIdOf(); + const socket = await connect({ + auth_token: user.token, + acks: ['demo.ack'], + }); + + expect( + socketService.has({ room: ackRoom(String(userId), 'demo.ack') }), + ).toBe(true); + for (const room of [accountSocketRoom(userId), socket.id!]) { + expect( + socketService.has({ room: ackRoom(room, 'demo.ack') }), + ).toBe(false); + } + await closeAll(userId, [socket]); + }); + it('hears nothing from a room nobody is in', async () => { await expect( socketService.askWithAck( diff --git a/src/backend/services/socket/SocketService.ts b/src/backend/services/socket/SocketService.ts index 442d95555..9907e61ae 100644 --- a/src/backend/services/socket/SocketService.ts +++ b/src/backend/services/socket/SocketService.ts @@ -681,13 +681,11 @@ export class SocketService extends PuterService { // user.id is numeric in the DB; stringify for room name // so adapter lookups key on a stable type. const rooms = socketRoomsFor(decision.accept); - const acks = handshakeAcks(handshakeAuth?.acks); + // Asks go to the user's or the app's room, never the others. socket.join([ ...rooms, - ...acks.flatMap((event) => - [...rooms, socket.id].map((room) => - ackRoom(room, event), - ), + ...handshakeAcks(handshakeAuth?.acks).map((event) => + ackRoom(rooms[0], event), ), ]); next();