# HG changeset patch # User Matthew Wild # Date 1540135075 -3600 # Node ID f2d70dc13700474dff2f2aca7617ba6602429fe3 # Parent 3bc5c22e2ca49562b2bc19a7d259a1c26952dc39 MUC: Include affiliation data when iterating over affiliations with a room diff -r 3bc5c22e2ca4 -r f2d70dc13700 plugins/muc/muc.lib.lua --- a/plugins/muc/muc.lib.lua Sun Oct 21 16:04:54 2018 +0100 +++ b/plugins/muc/muc.lib.lua Sun Oct 21 16:17:55 2018 +0100 @@ -1222,17 +1222,14 @@ -- Iterates over jid, affiliation pairs function room_mt:each_affiliation(with_affiliation) - if not with_affiliation then - return pairs(self._affiliations); - else - return function(_affiliations, jid) - local affiliation; - repeat -- Iterate until we get a match - jid, affiliation = next(_affiliations, jid); - until jid == nil or affiliation == with_affiliation - return jid, affiliation; - end, self._affiliations, nil - end + local _affiliations, _affiliation_data = self._affiliations, self._affiliation_data; + return function(_, jid) + local affiliation; + repeat -- Iterate until we get a match + jid, affiliation = next(_affiliations, jid); + until with_affiliation == nil or jid == nil or affiliation == with_affiliation + return jid, affiliation, _affiliation_data[jid]; + end, nil, nil; end function room_mt:set_affiliation(actor, jid, affiliation, reason, data)