changeset 3689:65e94270c413

mod_muc_hide_media: Also strip SIMS media
author Matthew Wild <mwild1@gmail.com>
date Sun, 29 Sep 2019 18:53:00 +0100
parents d4537f045a78
children 8c0a6d4541d5
files mod_muc_hide_media/mod_muc_hide_media.lua
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_muc_hide_media/mod_muc_hide_media.lua	Sun Sep 29 18:47:57 2019 +0100
+++ b/mod_muc_hide_media/mod_muc_hide_media.lua	Sun Sep 29 18:53:00 2019 +0100
@@ -47,11 +47,22 @@
 	formdata["{xmpp:prosody.im}muc#roomconfig_display_media"] = display_media;
 end);
 
+local function filter_media_tags(tag)
+	local xmlns = tag.attr.xmlns;
+	if xmlns == "jabber:x:oob" then
+		return nil;
+	elseif xmlns == "urn:xmpp:reference:0" then
+		if tag:get_child("media-sharing", "urn:xmpp:sims:1") then
+			return nil;
+		end
+	end
+	return tag;
+end
 
 module:hook("muc-occupant-groupchat", function (event)
 	local stanza = event.stanza;
 	if stanza.attr.type ~= "groupchat" then return; end
 	if should_hide_media(event.room) then
-		stanza:remove_children("x", "jabber:x:oob");
+		stanza:maptags(filter_media_tags);
 	end
 end, 20);