Mercurial > prosody-modules
diff mod_http_muc_log/mod_http_muc_log.lua @ 4963:479d618c9e6d
mod_http_muc_log: Show XEP-0444 reactions
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 26 Jun 2022 21:23:42 +0200 |
parents | 13070c6a7ce8 |
children | 8c7b7db69f5b |
line wrap: on
line diff
--- a/mod_http_muc_log/mod_http_muc_log.lua Mon Jun 20 18:24:32 2022 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Sun Jun 26 21:23:42 2022 +0200 @@ -368,6 +368,30 @@ end end + local reactions = item:get_child("reactions", "urn:xmpp:reactions:0"); + if reactions then + -- COMPAT Movim uses an @to attribute instead of the correct @id + local target_id = reactions.attr.id or reactions.attr.to; + for n = i - 1, 1, -1 do + if not logs[n] then + break -- Probably reached logs[0] + elseif logs[n].key == target_id then + local react_map = logs[n].reactions; -- { string : integer } + if not react_map then + react_map = {}; + logs[n].reactions = react_map; + end + for reaction_tag in reactions:childtags("reaction") do + -- FIXME This doesn't replace previous reactions by the same user + -- on the same message. + local reaction_text = reaction_tag:get_text() or "�"; + react_map[reaction_text] = (react_map[reaction_text] or 0) + 1; + end + break + end + end + end + if body or verb or oob then local line = { id = item.attr.id,