aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/muc/mod_muc.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2012-12-01 00:31:33 +0500
committerWaqas Hussain <waqas20@gmail.com>2012-12-01 00:31:33 +0500
commit8674db94117611ef4790c1d2859fd144c12dd7d1 (patch)
tree74e490c3a2d4ca6afc659fd9a071309b2c7a8cc4 /plugins/muc/mod_muc.lua
parentcbf14003e96012cf10c734f7d7442e416bf1d125 (diff)
parentd2b8f935c6abdab0c44375ffe110e32dedbe0b26 (diff)
downloadprosody-8674db94117611ef4790c1d2859fd144c12dd7d1.tar.gz
prosody-8674db94117611ef4790c1d2859fd144c12dd7d1.zip
Merge 0.9->trunk.
Diffstat (limited to 'plugins/muc/mod_muc.lua')
-rw-r--r--plugins/muc/mod_muc.lua23
1 files changed, 11 insertions, 12 deletions
diff --git a/plugins/muc/mod_muc.lua b/plugins/muc/mod_muc.lua
index bf29d1ca..0df8b790 100644
--- a/plugins/muc/mod_muc.lua
+++ b/plugins/muc/mod_muc.lua
@@ -77,17 +77,22 @@ local function room_save(room, forced)
if forced then datamanager.store(nil, muc_host, "persistent", persistent_rooms); end
end
+function create_room(jid)
+ local room = muc_new_room(jid);
+ room.route_stanza = room_route_stanza;
+ room.save = room_save;
+ rooms[jid] = room;
+ return room;
+end
+
local persistent_errors = false;
for jid in pairs(persistent_rooms) do
local node = jid_split(jid);
local data = datamanager.load(node, muc_host, "config");
if data then
- local room = muc_new_room(jid);
+ local room = create_room(jid);
room._data = data._data;
room._affiliations = data._affiliations;
- room.route_stanza = room_route_stanza;
- room.save = room_save;
- rooms[jid] = room;
else -- missing room data
persistent_rooms[jid] = nil;
module:log("error", "Missing data for room '%s', removing from persistent room list", jid);
@@ -149,10 +154,7 @@ function stanza_handler(event)
if not(restrict_room_creation) or
(restrict_room_creation == "admin" and is_admin(stanza.attr.from)) or
(restrict_room_creation == "local" and select(2, jid_split(stanza.attr.from)) == module.host:gsub("^[^%.]+%.", "")) then
- room = muc_new_room(bare);
- room.route_stanza = room_route_stanza;
- room.save = room_save;
- rooms[bare] = room;
+ room = create_room(bare);
end
end
if room then
@@ -190,14 +192,11 @@ module.save = function()
end
module.restore = function(data)
for jid, oldroom in pairs(data.rooms or {}) do
- local room = muc_new_room(jid);
+ local room = create_room(jid);
room._jid_nick = oldroom._jid_nick;
room._occupants = oldroom._occupants;
room._data = oldroom._data;
room._affiliations = oldroom._affiliations;
- room.route_stanza = room_route_stanza;
- room.save = room_save;
- rooms[jid] = room;
end
hosts[module:get_host()].muc = { rooms = rooms };
end