Comparison

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
parent 4930:13070c6a7ce8
child 4970:8c7b7db69f5b
comparison
equal deleted inserted replaced
4962:5a3031613dbc 4963:479d618c9e6d
366 -- Ignore unresolved edit. 366 -- Ignore unresolved edit.
367 edit = nil; 367 edit = nil;
368 end 368 end
369 end 369 end
370 370
371 local reactions = item:get_child("reactions", "urn:xmpp:reactions:0");
372 if reactions then
373 -- COMPAT Movim uses an @to attribute instead of the correct @id
374 local target_id = reactions.attr.id or reactions.attr.to;
375 for n = i - 1, 1, -1 do
376 if not logs[n] then
377 break -- Probably reached logs[0]
378 elseif logs[n].key == target_id then
379 local react_map = logs[n].reactions; -- { string : integer }
380 if not react_map then
381 react_map = {};
382 logs[n].reactions = react_map;
383 end
384 for reaction_tag in reactions:childtags("reaction") do
385 -- FIXME This doesn't replace previous reactions by the same user
386 -- on the same message.
387 local reaction_text = reaction_tag:get_text() or "�";
388 react_map[reaction_text] = (react_map[reaction_text] or 0) + 1;
389 end
390 break
391 end
392 end
393 end
394
371 if body or verb or oob then 395 if body or verb or oob then
372 local line = { 396 local line = {
373 id = item.attr.id, 397 id = item.attr.id,
374 key = key; 398 key = key;
375 datetime = datetime.datetime(when); 399 datetime = datetime.datetime(when);