Comparison

mod_muc_markers/mod_muc_markers.lua @ 4298:020dd0a59f1f

mod_muc_markers: Add option for @id rewriting, default off (may break some clients) XEP-0333 was updated to clarify that stanza-id should be used instead of the 'id' attribute when in a MUC. Some clients still use the id attribute, which is why we were rewriting it. Rewriting is bad because mod_muc advertises stable_id, indicating that Prosody does *not* rewrite ids. Recent versions of Conversations actually depend on this being true. All clients should migrate to using stanza-id for markers. See XEP-0333.
author Matthew Wild <mwild1@gmail.com>
date Mon, 14 Dec 2020 12:09:25 +0000
parent 4071:8e28d0918abc
child 4337:83f89ffe427b
comparison
equal deleted inserted replaced
4297:4a5c4a352b78 4298:020dd0a59f1f
19 for priority, name in ipairs(marker_order) do 19 for priority, name in ipairs(marker_order) do
20 marker_order[name] = priority; 20 marker_order[name] = priority;
21 end 21 end
22 22
23 local marker_element_name = module:get_option_string("muc_marker_type", "displayed"); 23 local marker_element_name = module:get_option_string("muc_marker_type", "displayed");
24 local rewrite_id_attribute = module:get_option_boolean("muc_marker_rewrite_id", false);
24 25
25 assert(marker_order[marker_element_name], "invalid marker name: "..marker_element_name); 26 assert(marker_order[marker_element_name], "invalid marker name: "..marker_element_name);
26 27
27 local marker_element_names = set.new(); 28 local marker_element_names = set.new();
28 29
48 49
49 local archive_id = get_stanza_id(stanza, event.room.jid); 50 local archive_id = get_stanza_id(stanza, event.room.jid);
50 -- We are not interested in stanzas that didn't get archived 51 -- We are not interested in stanzas that didn't get archived
51 if not archive_id then return; end 52 if not archive_id then return; end
52 53
53 -- Add stanza id as id attribute 54 if rewrite_id_attribute then
54 stanza.attr.id = archive_id; 55 -- Add stanza id as id attribute
56 stanza.attr.id = archive_id;
57 end
58
55 -- Add markable element to request markers from clients 59 -- Add markable element to request markers from clients
56 stanza:tag("markable", { xmlns = xmlns_markers }):up(); 60 stanza:tag("markable", { xmlns = xmlns_markers }):up();
57 end, -1); 61 end, -1);
58 62
59 module:hook("muc-occupant-groupchat", function (event) 63 module:hook("muc-occupant-groupchat", function (event)