mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): update WebsocketGateway unit tests
This commit is contained in:
@@ -416,6 +416,10 @@ export class WebsocketGateway
|
||||
async getNotificationSockets(
|
||||
sessionId: string,
|
||||
): Promise<RemoteSocket<DefaultEventsMap, any>[]> {
|
||||
if (!sessionId) {
|
||||
throw new Error('SessionId is required!');
|
||||
}
|
||||
|
||||
return (await this.io.fetchSockets()).filter(
|
||||
({ handshake, data }) =>
|
||||
!handshake.query.channel && data.sessionID === sessionId,
|
||||
@@ -429,8 +433,16 @@ export class WebsocketGateway
|
||||
* @param room - the joined room name
|
||||
*/
|
||||
async joinNotificationSockets(sessionId: string, room: Room): Promise<void> {
|
||||
if (!sessionId) {
|
||||
throw new Error('SessionId is required!');
|
||||
}
|
||||
|
||||
const notificationSockets = await this.getNotificationSockets(sessionId);
|
||||
|
||||
if (!notificationSockets.length) {
|
||||
throw new Error('No notification sockets found!');
|
||||
}
|
||||
|
||||
notificationSockets.forEach((notificationSocket) =>
|
||||
notificationSocket.join(room),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user