comparison mod_muc_thread_polyfill/mod_muc_thread_polyfill.lua @ 6351:1a08652c3fea

mod_muc_thread_polyfill: new module to infer threads when possible for clients that do not send them
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Fri, 26 Dec 2025 11:39:34 -0500
parents
children
comparison
equal deleted inserted replaced
6350:908d44cfb693 6351:1a08652c3fea
1 local st = require "util.stanza";
2 local jid = require "util.jid";
3
4 local archive = module:open_store("muc_log", "archive");
5
6 module:hook("muc-occupant-groupchat", function (event)
7 local stanza = event.stanza;
8 local room = event.room;
9
10 if stanza:get_child("thread") then
11 return;
12 end
13
14 local reply = stanza:get_child("reply", "urn:xmpp:reply:0");
15 if not reply then
16 return;
17 end
18
19 local reply_id = reply.attr.id;
20 if not reply_id then
21 return;
22 end
23
24 local archived = archive:get(jid.node(room.jid), reply_id);
25 if not archived then
26 return;
27 end
28
29 local parent_thread = archived:get_child("thread");
30 if parent_thread then
31 stanza:add_child(st.clone(parent_thread));
32 end
33 end);