Diff

mod_muc_markers/mod_muc_markers.lua @ 4033:7b6bcb91493e

mod_muc_markers: Allow tracking multiple markers
author Matthew Wild <mwild1@gmail.com>
date Thu, 21 May 2020 16:35:07 +0100
parent 4032:787fc3030087
child 4056:554f64c8d0c0
line wrap: on
line diff
--- a/mod_muc_markers/mod_muc_markers.lua	Thu May 21 16:34:46 2020 +0100
+++ b/mod_muc_markers/mod_muc_markers.lua	Thu May 21 16:35:07 2020 +0100
@@ -13,6 +13,7 @@
 local xmlns_markers = "urn:xmpp:chat-markers:0";
 
 local marker_element_name = module:get_option_string("muc_marker_type", "displayed");
+local marker_element_names = module:get_option_set("muc_marker_types", { marker_element_name });
 
 local muc_marker_map_store = module:open_store("muc_markers", "map");
 
@@ -39,8 +40,10 @@
 end, -1);
 
 module:hook("muc-occupant-groupchat", function (event)
-	local marker = event.stanza:get_child(marker_element_name, xmlns_markers);
-	if not marker then return; end
+	local marker = event.stanza:child_with_ns(xmlns_markers);
+	if not marker or not marker_element_names:contains(marker.name) then
+		return; -- No marker, or not one we are interested in
+	end
 
 	-- Store the id that the user has received to
 	module:log("warn", "New marker for %s: %s", event.occupant.bare_jid, marker.attr.id);