Comparison

plugins/muc/muc.lib.lua @ 6126:122e0f26e8f6

plugins/muc/muc.lib: Use `get_role` in `handle_admin_item_get_command`. Removed a TODO that's already done
author daurnimator <quae@daurnimator.com>
date Wed, 19 Mar 2014 17:46:25 -0400
parent 6125:4a35a0281d8a
child 6127:a66ebc5d0ab5
comparison
equal deleted inserted replaced
6125:4a35a0281d8a 6126:122e0f26e8f6
860 end 860 end
861 861
862 function room_mt:handle_admin_item_get_command(origin, stanza) 862 function room_mt:handle_admin_item_get_command(origin, stanza)
863 local actor = stanza.attr.from; 863 local actor = stanza.attr.from;
864 local affiliation = self:get_affiliation(actor); 864 local affiliation = self:get_affiliation(actor);
865 local current_nick = self:get_occupant_jid(actor);
866 local role = current_nick and self._occupants[current_nick].role or self:get_default_role(affiliation);
867 local item = stanza.tags[1].tags[1]; 865 local item = stanza.tags[1].tags[1];
868 local _aff = item.attr.affiliation; 866 local _aff = item.attr.affiliation;
869 local _rol = item.attr.role; 867 local _rol = item.attr.role;
870 if _aff and not _rol then 868 if _aff and not _rol then
871 if affiliation == "owner" or (affiliation == "admin" and _aff ~= "owner" and _aff ~= "admin") then 869 if affiliation == "owner" or (affiliation == "admin" and _aff ~= "owner" and _aff ~= "admin") then
880 else 878 else
881 origin.send(st.error_reply(stanza, "auth", "forbidden")); 879 origin.send(st.error_reply(stanza, "auth", "forbidden"));
882 return true; 880 return true;
883 end 881 end
884 elseif _rol and not _aff then 882 elseif _rol and not _aff then
883 local role = self:get_role(self:get_occupant_jid(actor)) or self:get_default_role(affiliation);
885 if role == "moderator" then 884 if role == "moderator" then
886 -- TODO allow admins and owners not in room? Provide read-only access to everyone who can see the participants anyway?
887 if _rol == "none" then _rol = nil; end 885 if _rol == "none" then _rol = nil; end
888 local reply = st.reply(stanza):query("http://jabber.org/protocol/muc#admin"); 886 local reply = st.reply(stanza):query("http://jabber.org/protocol/muc#admin");
889 for occupant_jid, occupant in pairs(self._occupants) do 887 for occupant_jid, occupant in pairs(self._occupants) do
890 if occupant.role == _rol then 888 if occupant.role == _rol then
891 reply:tag("item", { 889 reply:tag("item", {