# HG changeset patch # User daurnimator # Date 1398806294 14400 # Node ID 6b4ff34dc8ea71876f39e424fba400f6600a5251 # Parent 641756a6a5f75af2bc574f2595e86e07f1efc603 plugins/muc/mod_muc: Use module:shared instead of save/restore diff -r 641756a6a5f7 -r 6b4ff34dc8ea plugins/muc/mod_muc.lua --- a/plugins/muc/mod_muc.lua Tue Apr 29 15:13:06 2014 -0400 +++ b/plugins/muc/mod_muc.lua Tue Apr 29 17:18:14 2014 -0400 @@ -30,9 +30,8 @@ local um_is_admin = require "core.usermanager".is_admin; local hosts = prosody.hosts; -rooms = {}; -local rooms = rooms; - +local rooms = module:shared "rooms"; +_G.rooms = rooms; module:depends("disco"); module:add_identity("conference", "text", module:get_option_string("name", "Prosody Chatrooms")); @@ -203,31 +202,13 @@ end, -2) end -local saved = false; -module.save = function() - saved = true; - return {rooms = rooms}; -end -module.restore = function(data) - for jid, oldroom in pairs(data.rooms or {}) do - local room = create_room(jid); - room._jid_nick = oldroom._jid_nick; - room._occupants = oldroom._occupants; - room._data = oldroom._data; - room._affiliations = oldroom._affiliations; +function shutdown_component() + local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) + :tag("status", { code = "332"}):up(); + for roomjid, room in pairs(rooms) do + room:clear(x); end end - -function shutdown_component() - if not saved then - local x = st.stanza("x", {xmlns = "http://jabber.org/protocol/muc#user"}) - :tag("status", { code = "332"}):up(); - for roomjid, room in pairs(rooms) do - room:clear(x); - end - end -end -module.unload = shutdown_component; module:hook_global("server-stopping", shutdown_component); -- Ad-hoc commands