Software /
code /
prosody
Changeset
6234:cc8a6ca2d7c5
plugins/muc/mod_muc: Move affiliation monkey patch into own scope
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Mon, 28 Apr 2014 16:30:53 -0400 |
parents | 6231:bc12a8253f94 |
children | 6235:d433db49e353 |
files | plugins/muc/mod_muc.lua |
diffstat | 1 files changed, 13 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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)