# HG changeset patch # User Kim Alvefur # Date 1656271422 -7200 # Node ID 479d618c9e6d302b0c41bd703a29aef66586a958 # Parent 5a3031613dbc3478286f50605243e067188646fc mod_http_muc_log: Show XEP-0444 reactions diff -r 5a3031613dbc -r 479d618c9e6d mod_http_muc_log/mod_http_muc_log.lua --- 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, diff -r 5a3031613dbc -r 479d618c9e6d mod_http_muc_log/res/http_muc_log.html --- a/mod_http_muc_log/res/http_muc_log.html Mon Jun 20 18:24:32 2022 +0200 +++ b/mod_http_muc_log/res/http_muc_log.html Sun Jun 26 21:23:42 2022 +0200 @@ -44,6 +44,7 @@ .unavailable .verb{color:#c03030;} .button{display:inline-block} .button>a{color:white;background-color:orange;border-radius:4px} +.reaction{font-size:smaller;outline:1px solid silver;border-radius:2px} form{text-align:right} li.edited{display:none} li:target{outline:1px gray dotted;display:inherit} @@ -113,6 +114,7 @@ {item.nick} {item.verb?} {item.edited&}{item.body?}{item.edited& }{item.edit& } +{item.reactions%{idx} {item}} {item.oob.url&
{item.oob.desc?}
{item.oob.desc?}
} }