From 89c94701dc12b594b94b4f8ad213c36d5bba51d1 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Thu, 22 May 2014 19:50:26 -0700 Subject: [PATCH] Fix #368 --- lib/web/account.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/web/account.js b/lib/web/account.js index 5b9df74a..d091a639 100644 --- a/lib/web/account.js +++ b/lib/web/account.js @@ -291,7 +291,8 @@ function handleNewChannel(req, res) { var sv = Server.getServer(); if (sv.isChannelLoaded(name)) { var chan = sv.getChannel(name); - chan.users.forEach(function (u) { + var users = Array.prototype.slice.call(chan.users); + users.forEach(function (u) { u.kick("Channel reloading"); }); @@ -377,6 +378,19 @@ function handleDeleteChannel(req, res) { webserver.ipForRequest(req) + " deleted channel " + name); } + var sv = Server.getServer(); + if (sv.isChannelLoaded(name)) { + var chan = sv.getChannel(name); + chan.clearFlag(require("../flags").C_REGISTERED); + var users = Array.prototype.slice.call(chan.users); + users.forEach(function (u) { + u.kick("Channel reloading"); + }); + + if (!chan.dead) { + chan.emit("empty"); + } + } db.channels.listUserChannels(loginName, function (err2, channels) { sendJade(res, "account-channels", { loggedIn: true,