view mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua @ 5805:55b99f593c3a

mod_pubsub_serverinfo: Disco/info cache TTL should be configurable This module caches the disco/info results of remote domains. This commit introduces a new configuration option that allows an admin to configure the cache expiry duration.
author Guus der Kinderen <guus.der.kinderen@gmail.com>
date Thu, 04 Jan 2024 12:05:51 +0100
parents 2c69577b28c2
children
line wrap: on
line source

local bare_jid = require"util.jid".bare;
local mod_muc = module:depends("muc");

local function filter_avatar_advertisement(tag)
	if tag.attr.xmlns == "vcard-temp:x:update" then
		return nil;
	end

	return tag;
end

module:hook("presence/full", function(event)
	local stanza = event.stanza;
	local room = mod_muc.get_room_from_jid(bare_jid(stanza.attr.to));

	if not room:get_affiliation(stanza.attr.from) then
		stanza:maptags(filter_avatar_advertisement);
	end
end, 1);