Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 6236:ee996e679f15
plugins/muc/mod_muc: No need to treat the host room specially
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Mon, 28 Apr 2014 16:31:21 -0400 |
parent | 6235:d433db49e353 |
child | 6237:a58685df9d16 |
comparison
equal
deleted
inserted
replaced
6235:d433db49e353 | 6236:ee996e679f15 |
---|---|
10 | 10 |
11 if module:get_host_type() ~= "component" then | 11 if module:get_host_type() ~= "component" then |
12 error("MUC should be loaded as a component, please see http://prosody.im/doc/components", 0); | 12 error("MUC should be loaded as a component, please see http://prosody.im/doc/components", 0); |
13 end | 13 end |
14 | 14 |
15 local muc_host = module:get_host(); | |
16 local restrict_room_creation = module:get_option("restrict_room_creation"); | 15 local restrict_room_creation = module:get_option("restrict_room_creation"); |
17 if restrict_room_creation then | 16 if restrict_room_creation then |
18 if restrict_room_creation == true then | 17 if restrict_room_creation == true then |
19 restrict_room_creation = "admin"; | 18 restrict_room_creation = "admin"; |
20 elseif restrict_room_creation ~= "admin" and restrict_room_creation ~= "local" then | 19 elseif restrict_room_creation ~= "admin" and restrict_room_creation ~= "local" then |
117 module:log("error", "Missing data for room '%s', removing from persistent room list", jid); | 116 module:log("error", "Missing data for room '%s', removing from persistent room list", jid); |
118 persistent_errors = true; | 117 persistent_errors = true; |
119 end | 118 end |
120 end | 119 end |
121 if persistent_errors then persistent_rooms_storage:set(nil, persistent_rooms); end | 120 if persistent_errors then persistent_rooms_storage:set(nil, persistent_rooms); end |
122 | |
123 local host_room = muc_new_room(muc_host); | |
124 host_room.save = room_save; | |
125 rooms[muc_host] = host_room; | |
126 | 121 |
127 module:hook("host-disco-items", function(event) | 122 module:hook("host-disco-items", function(event) |
128 local reply = event.reply; | 123 local reply = event.reply; |
129 module:log("debug", "host-disco-items called"); | 124 module:log("debug", "host-disco-items called"); |
130 for jid, room in pairs(rooms) do | 125 for jid, room in pairs(rooms) do |
225 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) | 220 local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) |
226 :tag("status", { code = "332"}):up(); | 221 :tag("status", { code = "332"}):up(); |
227 for roomjid, room in pairs(rooms) do | 222 for roomjid, room in pairs(rooms) do |
228 room:clear(x); | 223 room:clear(x); |
229 end | 224 end |
230 host_room:clear(x); | |
231 end | 225 end |
232 end | 226 end |
233 module.unload = shutdown_component; | 227 module.unload = shutdown_component; |
234 module:hook_global("server-stopping", shutdown_component); | 228 module:hook_global("server-stopping", shutdown_component); |
235 | 229 |