changeset 5650:0eb2d5ea2428

merge
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Sat, 06 May 2023 19:40:23 -0500
parents 2c69577b28c2 (diff) 72f23107beb4 (current diff)
children b40750891bee
files
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_muc_restrict_avatars/mod_muc_restrict_avatars.lua	Sat May 06 19:40:23 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);