Software /
code /
prosody
Changeset
5210:862a6fae05e7
MUC: Expose create_room(jid).
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Fri, 30 Nov 2012 08:57:58 +0500 |
parents | 5209:f5d121846d53 |
children | 5211:80635a6cb126 |
files | plugins/muc/mod_muc.lua |
diffstat | 1 files changed, 11 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/mod_muc.lua Fri Nov 30 08:50:03 2012 +0500 +++ b/plugins/muc/mod_muc.lua Fri Nov 30 08:57:58 2012 +0500 @@ -77,17 +77,22 @@ 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 @@ 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 @@ 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