Software /
code /
prosody
Comparison
plugins/muc/muc.lib.lua @ 5542:329ebdfb39a2
MUC: Allow actor == true to set roles (like affiliations)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 29 Apr 2013 11:25:12 +0100 |
parent | 5541:1997671d5e46 |
child | 5577:8b09b0d068d4 |
comparison
equal
deleted
inserted
replaced
5541:1997671d5e46 | 5542:329ebdfb39a2 |
---|---|
1051 function room_mt:get_role(nick) | 1051 function room_mt:get_role(nick) |
1052 local session = self._occupants[nick]; | 1052 local session = self._occupants[nick]; |
1053 return session and session.role or nil; | 1053 return session and session.role or nil; |
1054 end | 1054 end |
1055 function room_mt:can_set_role(actor_jid, occupant_jid, role) | 1055 function room_mt:can_set_role(actor_jid, occupant_jid, role) |
1056 local occupant = self._occupants[occupant_jid]; | |
1057 if not occupant or not actor then return nil, "modify", "not-acceptable"; end | |
1058 | |
1059 if actor_jid == true then return true; end | |
1060 | |
1056 local actor = self._occupants[self._jid_nick[actor_jid]]; | 1061 local actor = self._occupants[self._jid_nick[actor_jid]]; |
1057 local occupant = self._occupants[occupant_jid]; | |
1058 | |
1059 if not occupant or not actor then return nil, "modify", "not-acceptable"; end | |
1060 | |
1061 if actor.role == "moderator" then | 1062 if actor.role == "moderator" then |
1062 if occupant.affiliation ~= "owner" and occupant.affiliation ~= "admin" then | 1063 if occupant.affiliation ~= "owner" and occupant.affiliation ~= "admin" then |
1063 if actor.affiliation == "owner" or actor.affiliation == "admin" then | 1064 if actor.affiliation == "owner" or actor.affiliation == "admin" then |
1064 return true; | 1065 return true; |
1065 elseif occupant.role ~= "moderator" and role ~= "moderator" then | 1066 elseif occupant.role ~= "moderator" and role ~= "moderator" then |