Mercurial > prosody-hg
comparison plugins/muc/muc.lib.lua @ 9531:f2d70dc13700
MUC: Include affiliation data when iterating over affiliations with a room
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 21 Oct 2018 16:17:55 +0100 |
| parents | 3bc5c22e2ca4 |
| children | 9bb33edd7255 |
comparison
equal
deleted
inserted
replaced
| 9530:3bc5c22e2ca4 | 9531:f2d70dc13700 |
|---|---|
| 1220 return result; | 1220 return result; |
| 1221 end | 1221 end |
| 1222 | 1222 |
| 1223 -- Iterates over jid, affiliation pairs | 1223 -- Iterates over jid, affiliation pairs |
| 1224 function room_mt:each_affiliation(with_affiliation) | 1224 function room_mt:each_affiliation(with_affiliation) |
| 1225 if not with_affiliation then | 1225 local _affiliations, _affiliation_data = self._affiliations, self._affiliation_data; |
| 1226 return pairs(self._affiliations); | 1226 return function(_, jid) |
| 1227 else | 1227 local affiliation; |
| 1228 return function(_affiliations, jid) | 1228 repeat -- Iterate until we get a match |
| 1229 local affiliation; | 1229 jid, affiliation = next(_affiliations, jid); |
| 1230 repeat -- Iterate until we get a match | 1230 until with_affiliation == nil or jid == nil or affiliation == with_affiliation |
| 1231 jid, affiliation = next(_affiliations, jid); | 1231 return jid, affiliation, _affiliation_data[jid]; |
| 1232 until jid == nil or affiliation == with_affiliation | 1232 end, nil, nil; |
| 1233 return jid, affiliation; | |
| 1234 end, self._affiliations, nil | |
| 1235 end | |
| 1236 end | 1233 end |
| 1237 | 1234 |
| 1238 function room_mt:set_affiliation(actor, jid, affiliation, reason, data) | 1235 function room_mt:set_affiliation(actor, jid, affiliation, reason, data) |
| 1239 module:log("debug", "data is %s", tostring(data)); | 1236 module:log("debug", "data is %s", tostring(data)); |
| 1240 if not actor then return nil, "modify", "not-acceptable"; end; | 1237 if not actor then return nil, "modify", "not-acceptable"; end; |
