Diff

mod_http_muc_log/mod_http_muc_log.lua @ 4592:38f501dca618

mod_http_muc_log: Find edit relations using XEP-0308
author Kim Alvefur <zash@zash.se>
date Tue, 15 Jun 2021 17:35:56 +0200
parent 4590:3145823992cb
child 4676:a2cf3b69a3d6
line wrap: on
line diff
--- 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 = {