comparison mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua @ 5649:2c69577b28c2

mod_muc_restrict_avatars: Block MUC participant avatars for non-members
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Wed, 22 Feb 2023 22:47:45 -0500
parents
children
comparison
equal deleted inserted replaced
5177:f6b5f04d4b28 5649:2c69577b28c2
1 local bare_jid = require"util.jid".bare;
2 local mod_muc = module:depends("muc");
3
4 local function filter_avatar_advertisement(tag)
5 if tag.attr.xmlns == "vcard-temp:x:update" then
6 return nil;
7 end
8
9 return tag;
10 end
11
12 module:hook("presence/full", function(event)
13 local stanza = event.stanza;
14 local room = mod_muc.get_room_from_jid(bare_jid(stanza.attr.to));
15
16 if not room:get_affiliation(stanza.attr.from) then
17 stanza:maptags(filter_avatar_advertisement);
18 end
19 end, 1);