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,