Comparison

mod_http_muc_log/mod_http_muc_log.lua @ 4992:ed5abb8b8fa8

mod_http_muc_log: Use XEP-0421 ID over nickname for XEP-0308 This prevents someone else from joining with the same nickname as someone who left, and "correcting" their messages.
author Kim Alvefur <zash@zash.se>
date Tue, 16 Aug 2022 01:41:45 +0200
parent 4991:b17d63ef5bdf
child 4993:f36d15107c15
comparison
equal deleted inserted replaced
4991:b17d63ef5bdf 4992:ed5abb8b8fa8
324 verb = item.attr.type == "unavailable" and "has left" or "has joined"; 324 verb = item.attr.type == "unavailable" and "has left" or "has joined";
325 lang = "en"; 325 lang = "en";
326 end 326 end
327 327
328 local nick = select(3, jid_split(item.attr.from)); 328 local nick = select(3, jid_split(item.attr.from));
329 local occupant_id = item:find("{urn:xmpp:occupant-id:0}occupant-id@id") or nick;
329 330
330 -- XEP-0066: Out of Band Data 331 -- XEP-0066: Out of Band Data
331 local oob = use_oob and item:get_child("x", "jabber:x:oob"); 332 local oob = use_oob and item:get_child("x", "jabber:x:oob");
332 333
333 -- XEP-0425: Message Moderation 334 -- XEP-0425: Message Moderation
349 -- XEP-0308: Last Message Correction 350 -- XEP-0308: Last Message Correction
350 local edit = item:find("{urn:xmpp:message-correct:0}replace/@id"); 351 local edit = item:find("{urn:xmpp:message-correct:0}replace/@id");
351 if edit then 352 if edit then
352 local found = false; 353 local found = false;
353 for n = i-1, 1, -1 do 354 for n = i-1, 1, -1 do
354 if logs[n].message_id == edit and nick == logs[n].nick then 355 if logs[n].message_id == edit and occupant_id == logs[n].occupant_id then
355 found = true; 356 found = true;
356 logs[n].edited = archive_id; 357 logs[n].edited = archive_id;
357 edit = logs[n].archive_id; 358 edit = logs[n].archive_id;
358 break; 359 break;
359 end 360 end
392 393
393 if body or verb or oob then 394 if body or verb or oob then
394 local line = { 395 local line = {
395 message_id = message_id; 396 message_id = message_id;
396 archive_id = archive_id; 397 archive_id = archive_id;
398 occupant_id = occupant_id;
397 datetime = datetime.datetime(when); 399 datetime = datetime.datetime(when);
398 time = datetime.time(when); 400 time = datetime.time(when);
399 verb = verb; 401 verb = verb;
400 body = body; 402 body = body;
401 lang = lang; 403 lang = lang;