# HG changeset patch # User Kim Alvefur # Date 1623771356 -7200 # Node ID 38f501dca61817ddcf57784c3988d19237240b21 # Parent 327c7cacd89f5544c9ea75376e2e4c62cb73d510 mod_http_muc_log: Find edit relations using XEP-0308 diff -r 327c7cacd89f -r 38f501dca618 mod_http_muc_log/mod_http_muc_log.lua --- a/mod_http_muc_log/mod_http_muc_log.lua Tue Jun 15 17:22:33 2021 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Tue Jun 15 17:35:56 2021 +0200 @@ -330,8 +330,28 @@ local nick = select(3, jid_split(item.attr.from)); local oob = use_oob and item:get_child("x", "jabber:x:oob"); + local edit = item:find("{urn:xmpp:message-correct:0}replace/@id"); + if edit then + local found = false; + for n = i-1, 1, -1 do + if not logs[n] then + break; -- Probably reached logs[0] + elseif logs[n].id == edit and nick == logs[n].nick then + found = true; + logs[n].edited = key; + edit = logs[n].key; + break; + end + end + if not found then + -- Ignore unresolved edit. + edit = nil; + end + end + if body or verb or oob then local line = { + id = item.attr.id, key = key; datetime = datetime.datetime(when); time = datetime.time(when); @@ -341,6 +361,7 @@ nick = nick; st_name = item.name; st_type = item.attr.type; + edit = edit; }; if oob then line.oob = { diff -r 327c7cacd89f -r 38f501dca618 mod_http_muc_log/res/http_muc_log.html --- a/mod_http_muc_log/res/http_muc_log.html Tue Jun 15 17:22:33 2021 +0200 +++ b/mod_http_muc_log/res/http_muc_log.html Tue Jun 15 17:35:56 2021 +0200 @@ -45,7 +45,8 @@ .button{display:inline-block} .button>a{color:white;background-color:orange;border-radius:4px} form{text-align:right} -li:target{outline:1px gray dotted} +li.edited{display:none} +li:target{outline:1px gray dotted;display:inherit} @media (prefers-color-scheme: dark) { html{color:#eee} body{background-color:#161616} @@ -107,11 +108,11 @@
    {lines# -
  1. +
  2. {item.nick} {item.verb?} -{item.body?} +{item.edited&}{item.body?}{item.edited& }{item.edit& } {item.oob.url&
    {item.oob.desc?}
    {item.oob.desc?}
    }
  3. }