# HG changeset patch # User Stephen Paul Weber # Date 1766767174 18000 # Node ID 1a08652c3feac12d1a4535b0aaffb5e73bd0d307 # Parent 908d44cfb693c982c084895d44ad45a2a8af4d13 mod_muc_thread_polyfill: new module to infer threads when possible for clients that do not send them diff -r 908d44cfb693 -r 1a08652c3fea mod_muc_thread_polyfill/README.md --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_thread_polyfill/README.md Fri Dec 26 11:39:34 2025 -0500 @@ -0,0 +1,21 @@ +--- +labels: +- 'Stage-Beta' +summary: 'Infer threads for clients that do not send them' +... + +Introduction +============ + +Some clients have no UI for determining what a message should have, +but do support XEP-0461 replies. This module will infer the right thread from +the parent if there is none but this is a reply. + +Compatibility +============= + + ----- -------------------------------------------------- + trunk Works + 0.13 Works + 0.12 Works + ----- -------------------------------------------------- diff -r 908d44cfb693 -r 1a08652c3fea mod_muc_thread_polyfill/mod_muc_thread_polyfill.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_muc_thread_polyfill/mod_muc_thread_polyfill.lua Fri Dec 26 11:39:34 2025 -0500 @@ -0,0 +1,33 @@ +local st = require "util.stanza"; +local jid = require "util.jid"; + +local archive = module:open_store("muc_log", "archive"); + +module:hook("muc-occupant-groupchat", function (event) + local stanza = event.stanza; + local room = event.room; + + if stanza:get_child("thread") then + return; + end + + local reply = stanza:get_child("reply", "urn:xmpp:reply:0"); + if not reply then + return; + end + + local reply_id = reply.attr.id; + if not reply_id then + return; + end + + local archived = archive:get(jid.node(room.jid), reply_id); + if not archived then + return; + end + + local parent_thread = archived:get_child("thread"); + if parent_thread then + stanza:add_child(st.clone(parent_thread)); + end +end);