plugins/muc/mod_muc.lua

changeset 3604
3e89f0509967
parent 3589
1792610e169e
child 3628
576103409c7a
equal deleted inserted replaced
3603:fdc671381411 3604:3e89f0509967
21 elseif restrict_room_creation ~= "admin" and restrict_room_creation ~= "local" then 21 elseif restrict_room_creation ~= "admin" and restrict_room_creation ~= "local" then
22 restrict_room_creation = nil; 22 restrict_room_creation = nil;
23 end 23 end
24 end 24 end
25 local muc_new_room = module:require "muc".new_room; 25 local muc_new_room = module:require "muc".new_room;
26 local register_component = require "core.componentmanager".register_component;
27 local deregister_component = require "core.componentmanager".deregister_component;
28 local jid_split = require "util.jid".split; 26 local jid_split = require "util.jid".split;
29 local jid_bare = require "util.jid".bare; 27 local jid_bare = require "util.jid".bare;
30 local st = require "util.stanza"; 28 local st = require "util.stanza";
31 local uuid_gen = require "util.uuid".generate; 29 local uuid_gen = require "util.uuid".generate;
32 local datamanager = require "util.datamanager"; 30 local datamanager = require "util.datamanager";
161 module:hook("presence/full", stanza_handler); 159 module:hook("presence/full", stanza_handler);
162 module:hook("iq/host", stanza_handler); 160 module:hook("iq/host", stanza_handler);
163 module:hook("message/host", stanza_handler); 161 module:hook("message/host", stanza_handler);
164 module:hook("presence/host", stanza_handler); 162 module:hook("presence/host", stanza_handler);
165 163
166 component = register_component(muc_host, function() end); 164 hosts[module.host].send = function(stanza) -- FIXME do a generic fix
167 function component.send(stanza) -- FIXME do a generic fix
168 if stanza.attr.type == "result" or stanza.attr.type == "error" then 165 if stanza.attr.type == "result" or stanza.attr.type == "error" then
169 core_post_stanza(component, stanza); 166 core_post_stanza(component, stanza);
170 else error("component.send only supports result and error stanzas at the moment"); end 167 else error("component.send only supports result and error stanzas at the moment"); end
171 end 168 end
172 169
173 prosody.hosts[module:get_host()].muc = { rooms = rooms }; 170 prosody.hosts[module:get_host()].muc = { rooms = rooms };
174 171
175 module.unload = function()
176 deregister_component(muc_host);
177 end
178 module.save = function() 172 module.save = function()
179 return {rooms = rooms}; 173 return {rooms = rooms};
180 end 174 end
181 module.restore = function(data) 175 module.restore = function(data)
182 for jid, oldroom in pairs(data.rooms or {}) do 176 for jid, oldroom in pairs(data.rooms or {}) do

mercurial