Mercurial > prosody-modules
changeset 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 | 908d44cfb693 |
| children | 525655adfd3e |
| files | mod_muc_thread_polyfill/README.md mod_muc_thread_polyfill/mod_muc_thread_polyfill.lua |
| diffstat | 2 files changed, 54 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 <thread/> 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 + ----- --------------------------------------------------
--- /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);
