fix quit for clients that dont send quit before disconnect

This commit is contained in:
zefie
2025-06-25 17:31:11 -04:00
parent 6fbf5402de
commit 3ce9d0d50c

View File

@@ -2971,20 +2971,21 @@ class WTVIRC {
// Cleans up the user session and removes them from all channels
const nickname = this.nicknames.get(socket);
if (nickname) {
if (!socket.signedoff) {
var serverSocket = null;
for (const [srvSocket, users] of this.serverusers.entries()) {
if (users && typeof users.has === 'function' && users.has(nickname)) {
// Don't send QUIT to this server, as it owns the user
serverSocket = srvSocket;
continue;
}
}
await this.broadcastUser(nickname, `:${nickname}!${socket.username}@${socket.host} QUIT :Client disconnected\r\n`, socket);
await this.broadcastToAllServers(`:${socket.uniqueId} QUIT :Client disconnected\r\n`, serverSocket);
socket.signedoff = true; // Just in case
}
this.cleanupUserSession(nickname);
this.nicknames.delete(socket);
}
if (!socket.signedoff) {
var serverSocket = null;
for (const [srvSocket, users] of this.serverusers.entries()) {
if (users && typeof users.has === 'function' && users.has(nickname)) {
// Don't send QUIT to this server, as it owns the user
serverSocket = srvSocket;
continue;
}
}
await this.broadcastToAllServers(`:${socket.uniqueId} QUIT :Client disconnected\r\n`, serverSocket);
socket.signedoff = true; // Just in case
}
if (socket.isserver) {
const srvUsers = this.serverusers.get(socket) || [];