plugins/muc/muc.lib.lua
changeset 9619 66c6edf56397
parent 9617 4d7b925652d9
child 9645 0ce404230388
equal deleted inserted replaced
9618:7d1dbacda48a 9619:66c6edf56397
    37 function room_mt:__tostring()
    37 function room_mt:__tostring()
    38 	return "MUC room ("..self.jid..")";
    38 	return "MUC room ("..self.jid..")";
    39 end
    39 end
    40 
    40 
    41 function room_mt.save()
    41 function room_mt.save()
    42 	-- overriden by mod_muc.lua
    42 	-- overridden by mod_muc.lua
    43 end
    43 end
    44 
    44 
    45 function room_mt:get_occupant_jid(real_jid)
    45 function room_mt:get_occupant_jid(real_jid)
    46 	return self._jid_nick[real_jid]
    46 	return self._jid_nick[real_jid]
    47 end
    47 end
   277 		self_x = st.clone(x.self or base_x);
   277 		self_x = st.clone(x.self or base_x);
   278 		self:build_item_list(occupant, self_x, false, nick, actor_nick, nil, reason);
   278 		self:build_item_list(occupant, self_x, false, nick, actor_nick, nil, reason);
   279 		self_p = st.clone(base_presence):add_child(self_x);
   279 		self_p = st.clone(base_presence):add_child(self_x);
   280 	end
   280 	end
   281 
   281 
   282 	-- General populance
   282 	-- General populace
   283 	for occupant_nick, n_occupant in self:each_occupant() do
   283 	for occupant_nick, n_occupant in self:each_occupant() do
   284 		if occupant_nick ~= occupant.nick then
   284 		if occupant_nick ~= occupant.nick then
   285 			local pr;
   285 			local pr;
   286 			if can_see_real_jids(whois, n_occupant) then
   286 			if can_see_real_jids(whois, n_occupant) then
   287 				pr = get_full_p();
   287 				pr = get_full_p();
   607 				-- self:build_item_list(orig_occupant, x, false, dest_nick);
   607 				-- self:build_item_list(orig_occupant, x, false, dest_nick);
   608 				add_item(x, self:get_affiliation(bare_jid), orig_occupant.role, real_jid, dest_nick);
   608 				add_item(x, self:get_affiliation(bare_jid), orig_occupant.role, real_jid, dest_nick);
   609 				x:tag("status", {code = "303";}):up();
   609 				x:tag("status", {code = "303";}):up();
   610 				x:tag("status", {code = "110";}):up();
   610 				x:tag("status", {code = "110";}):up();
   611 				self:route_stanza(generated_unavail:add_child(x));
   611 				self:route_stanza(generated_unavail:add_child(x));
   612 				dest_nick = nil; -- set dest_nick to nil; so general populance doesn't see it for whole orig_occupant
   612 				dest_nick = nil; -- set dest_nick to nil; so general populace doesn't see it for whole orig_occupant
   613 			end
   613 			end
   614 		end
   614 		end
   615 
   615 
   616 		self:save_occupant(orig_occupant);
   616 		self:save_occupant(orig_occupant);
   617 		self:publicise_occupant_status(orig_occupant, orig_x, dest_nick);
   617 		self:publicise_occupant_status(orig_occupant, orig_x, dest_nick);
   964 	local item = stanza.tags[1].tags[1];
   964 	local item = stanza.tags[1].tags[1];
   965 	local _aff = item.attr.affiliation;
   965 	local _aff = item.attr.affiliation;
   966 	local _aff_rank = valid_affiliations[_aff or "none"];
   966 	local _aff_rank = valid_affiliations[_aff or "none"];
   967 	local _rol = item.attr.role;
   967 	local _rol = item.attr.role;
   968 	if _aff and _aff_rank and not _rol then
   968 	if _aff and _aff_rank and not _rol then
   969 		-- You need to be at least an admin, and be requesting info about your affifiliation or lower
   969 		-- You need to be at least an admin, and be requesting info about your affiliation or lower
   970 		-- e.g. an admin can't ask for a list of owners
   970 		-- e.g. an admin can't ask for a list of owners
   971 		local affiliation_rank = valid_affiliations[affiliation or "none"];
   971 		local affiliation_rank = valid_affiliations[affiliation or "none"];
   972 		if (affiliation_rank >= valid_affiliations.admin and affiliation_rank >= _aff_rank)
   972 		if (affiliation_rank >= valid_affiliations.admin and affiliation_rank >= _aff_rank)
   973 		or (self:get_whois() == "anyone") then
   973 		or (self:get_whois() == "anyone") then
   974 			local reply = st.reply(stanza):query("http://jabber.org/protocol/muc#admin");
   974 			local reply = st.reply(stanza):query("http://jabber.org/protocol/muc#admin");
  1289 	for nick, occupant in self:each_occupant() do -- luacheck: ignore 213
  1289 	for nick, occupant in self:each_occupant() do -- luacheck: ignore 213
  1290 		if occupant.bare_jid == jid or (
  1290 		if occupant.bare_jid == jid or (
  1291 			-- Outcast can be by host.
  1291 			-- Outcast can be by host.
  1292 			is_host_only and affiliation == "outcast" and select(2, jid_split(occupant.bare_jid)) == host
  1292 			is_host_only and affiliation == "outcast" and select(2, jid_split(occupant.bare_jid)) == host
  1293 		) then
  1293 		) then
  1294 			-- need to publcize in all cases; as affiliation in <item/> has changed.
  1294 			-- need to publicize in all cases; as affiliation in <item/> has changed.
  1295 			occupants_updated[occupant] = occupant.role;
  1295 			occupants_updated[occupant] = occupant.role;
  1296 			if occupant.role ~= role and (
  1296 			if occupant.role ~= role and (
  1297 				is_downgrade or
  1297 				is_downgrade or
  1298 				valid_roles[occupant.role or "none"] < role_rank -- upgrade
  1298 				valid_roles[occupant.role or "none"] < role_rank -- upgrade
  1299 			) then
  1299 			) then