fix(api): apply coderabbitai feedback

This commit is contained in:
yassinedorbozgithub 2025-05-13 09:39:22 +01:00
parent dfc05a7ce2
commit 9b97983977

View File

@ -114,8 +114,8 @@ export class WebsocketGateway
this.io.to(subscriber.foreign_id).emit(type, content); this.io.to(subscriber.foreign_id).emit(type, content);
} }
async createAndStoreSession(client: Socket) { async createAndStoreSession(client: Socket): Promise<void> {
return new Promise((resolve, reject) => { return new Promise<void>((resolve, reject) => {
const sid = uid(24); // Sign the sessionID before sending const sid = uid(24); // Sign the sessionID before sending
const signedSid = 's:' + signature.sign(sid, config.session.secret); const signedSid = 's:' + signature.sign(sid, config.session.secret);
// Send session ID to client to set cookie // Send session ID to client to set cookie
@ -146,6 +146,7 @@ export class WebsocketGateway
// Optionally set the cookie on the client's handshake object if needed // Optionally set the cookie on the client's handshake object if needed
client.handshake.headers.cookie = cookies; client.handshake.headers.cookie = cookies;
client.data.session = newSession; client.data.session = newSession;
client.data.sessionID = sid;
this.logger.verbose(` this.logger.verbose(`
Could not fetch session, since connecting socket has no cookie in its handshake. Could not fetch session, since connecting socket has no cookie in its handshake.
Generated a one-time-use cookie: Generated a one-time-use cookie:
@ -161,7 +162,7 @@ export class WebsocketGateway
> To work around this, either supply a cookie manually, or ignore this message and use an > To work around this, either supply a cookie manually, or ignore this message and use an
> approach other than sessions-- e.g. an auth token.) > approach other than sessions-- e.g. an auth token.)
`); `);
return resolve(true); return resolve();
}); });
}); });
} }