mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua
author Kim Alvefur <zash@zash.se>
Wed, 24 Jan 2024 17:55:26 +0100
changeset 5834 b109773ce6fe
parent 5653 2c69577b28c2
child 5885 66e7d46b1d4b
permissions -rw-r--r--
mod_http_oauth2: Reuse JWT issuance time as substitute for auth time Makes the token shorter. Since iat and auth_time are generated at about the same time they would only differ by a few microseconds anyway.

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);