# HG changeset patch # User daurnimator # Date 1398717053 14400 # Node ID cc8a6ca2d7c5374698bb57ddb61f476c94e1d7fb # Parent bc12a8253f9435c002f23e027c94027bd7c4db8b plugins/muc/mod_muc: Move affiliation monkey patch into own scope diff -r bc12a8253f94 -r cc8a6ca2d7c5 plugins/muc/mod_muc.lua --- a/plugins/muc/mod_muc.lua Mon Apr 21 17:51:32 2014 -0400 +++ b/plugins/muc/mod_muc.lua Mon Apr 28 16:30:53 2014 -0400 @@ -26,6 +26,7 @@ local muclib = module:require "muc"; local muc_new_room = muclib.new_room; +room_mt = muclib.room_mt; -- Yes, global. local persistent = module:require "muc/persistent"; local jid_split = require "util.jid".split; local jid_bare = require "util.jid".bare; @@ -52,16 +53,18 @@ return um_is_admin(jid, module.host); end -room_mt = muclib.room_mt; -- Yes, global. -local _set_affiliation = room_mt.set_affiliation; -local _get_affiliation = room_mt.get_affiliation; -function muclib.room_mt:get_affiliation(jid) - if is_admin(jid) then return "owner"; end - return _get_affiliation(self, jid); -end -function muclib.room_mt:set_affiliation(actor, jid, affiliation, callback, reason) - if is_admin(jid) then return nil, "modify", "not-acceptable"; end - return _set_affiliation(self, actor, jid, affiliation, callback, reason); +do -- Monkey patch to make server admins room owners + local _get_affiliation = room_mt.get_affiliation; + function room_mt:get_affiliation(jid) + if is_admin(jid) then return "owner"; end + return _get_affiliation(self, jid); + end + + local _set_affiliation = room_mt.set_affiliation; + function room_mt:set_affiliation(actor, jid, ...) + if is_admin(jid) then return nil, "modify", "not-acceptable"; end + return _set_affiliation(self, actor, jid, ...); + end end local function room_save(room, forced)