Diff

mod_muc_hide_media/mod_muc_hide_media.lua @ 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
parent 3681:d267e381255f
child 4788:9084588c73ae
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);