plugins/muc/muc.lib.lua
changeset 6478 3c815a64042b
parent 6457 6842b07fc7bc
child 6479 fb8a9873728b
equal deleted inserted replaced
6477:ee13d7dfa988 6478:3c815a64042b
   998 	affiliation = affiliation ~= "none" and affiliation or nil; -- coerces `affiliation == false` to `nil`
   998 	affiliation = affiliation ~= "none" and affiliation or nil; -- coerces `affiliation == false` to `nil`
   999 
   999 
  1000 	local target_affiliation = self._affiliations[jid]; -- Raw; don't want to check against host
  1000 	local target_affiliation = self._affiliations[jid]; -- Raw; don't want to check against host
  1001 	local is_downgrade = valid_affiliations[target_affiliation or "none"] > valid_affiliations[affiliation or "none"];
  1001 	local is_downgrade = valid_affiliations[target_affiliation or "none"] > valid_affiliations[affiliation or "none"];
  1002 
  1002 
  1003 	if actor ~= true then
  1003 	if actor == true then
       
  1004 		actor = nil -- So we can pass it safely to 'publicise_occupant_status' below
       
  1005 	else
  1004 		local actor_affiliation = self:get_affiliation(actor);
  1006 		local actor_affiliation = self:get_affiliation(actor);
  1005 		if actor_affiliation == "owner" then
  1007 		if actor_affiliation == "owner" then
  1006 			if jid_bare(actor) == jid then -- self change
  1008 			if jid_bare(actor) == jid then -- self change
  1007 				-- need at least one owner
  1009 				-- need at least one owner
  1008 				local is_last = true;
  1010 				local is_last = true;
  1096 	if valid_roles[role or "none"] == nil then
  1098 	if valid_roles[role or "none"] == nil then
  1097 		return nil, "modify", "not-acceptable";
  1099 		return nil, "modify", "not-acceptable";
  1098 	end
  1100 	end
  1099 	role = role ~= "none" and role or nil; -- coerces `role == false` to `nil`
  1101 	role = role ~= "none" and role or nil; -- coerces `role == false` to `nil`
  1100 
  1102 
  1101 	if actor ~= true then
  1103 	if actor == true then
       
  1104 		actor = nil -- So we can pass it safely to 'publicise_occupant_status' below
       
  1105 	else
  1102 		-- Can't do anything to other owners or admins
  1106 		-- Can't do anything to other owners or admins
  1103 		local occupant_affiliation = self:get_affiliation(occupant.bare_jid);
  1107 		local occupant_affiliation = self:get_affiliation(occupant.bare_jid);
  1104 		if occupant_affiliation == "owner" and occupant_affiliation == "admin" then
  1108 		if occupant_affiliation == "owner" and occupant_affiliation == "admin" then
  1105 			return nil, "cancel", "not-allowed";
  1109 			return nil, "cancel", "not-allowed";
  1106 		end
  1110 		end