plugins/muc/muc.lib.lua
changeset 6185 d4a8840e72f9
parent 6184 2bfc4b12ec8f
child 6186 85f7cd91dc31
equal deleted inserted replaced
6184:2bfc4b12ec8f 6185:d4a8840e72f9
   271 		end
   271 		end
   272 	end
   272 	end
   273 end
   273 end
   274 
   274 
   275 function room_mt:send_occupant_list(to, filter)
   275 function room_mt:send_occupant_list(to, filter)
   276 	local to_occupant = self:get_occupant_by_real_jid(to);
   276 	local to_bare = jid_bare(to);
   277 	local has_anonymous = self:get_whois() ~= "anyone"
   277 	local is_anonymous = true;
       
   278 	if self:get_whois() ~= "anyone" then
       
   279 		local affiliation = self:get_affiliation(to);
       
   280 		if affiliation ~= "admin" and affiliation ~= "owner" then
       
   281 			local occupant = self:get_occupant_by_real_jid(to);
       
   282 			if not occupant or occupant.role ~= "moderator" then
       
   283 				is_anonymous = false;
       
   284 			end
       
   285 		end
       
   286 	end
   278 	for occupant_jid, occupant in self:each_occupant() do
   287 	for occupant_jid, occupant in self:each_occupant() do
   279 		if filter == nil or filter(occupant_jid, occupant) then
   288 		if filter == nil or filter(occupant_jid, occupant) then
   280 			local x = st.stanza("x", {xmlns='http://jabber.org/protocol/muc#user'});
   289 			local x = st.stanza("x", {xmlns='http://jabber.org/protocol/muc#user'});
   281 			local is_anonymous = has_anonymous and occupant.role ~= "moderator" and to_occupant.bare_jid ~= occupant.bare_jid;
   290 			self:build_item_list(occupant, x, is_anonymous and to_bare ~= occupant.bare_jid); -- can always see your own jids
   282 			self:build_item_list(occupant, x, is_anonymous);
       
   283 			local pres = st.clone(occupant:get_presence());
   291 			local pres = st.clone(occupant:get_presence());
   284 			pres.attr.to = to;
   292 			pres.attr.to = to;
   285 			pres:add_child(x);
   293 			pres:add_child(x);
   286 			self:route_stanza(pres);
   294 			self:route_stanza(pres);
   287 		end
   295 		end