# HG changeset patch # User Stephen Paul Weber # Date 1677124065 18000 # Node ID 2c69577b28c260a3e1b11fc4b70c30aa6c32f76e # Parent f6b5f04d4b28024824d1f1b4fade9f357524e591 mod_muc_restrict_avatars: Block MUC participant avatars for non-members diff -r f6b5f04d4b28 -r 2c69577b28c2 mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua Wed Feb 22 22:47:45 2023 -0500 @@ -0,0 +1,19 @@ +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);