Software /
code /
prosody-modules
Comparison
mod_http_muc_log/mod_http_muc_log.lua @ 4990:d55b10878e43
mod_http_muc_log: Rename variable for improved clarity
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 16 Aug 2022 01:34:27 +0200 |
parent | 4989:b74d592df9e2 |
child | 4991:b17d63ef5bdf |
comparison
equal
deleted
inserted
replaced
4989:b74d592df9e2 | 4990:d55b10878e43 |
---|---|
303 module:log("warn", "Could not search archive: %s", err or "no error"); | 303 module:log("warn", "Could not search archive: %s", err or "no error"); |
304 return 500; | 304 return 500; |
305 end | 305 end |
306 | 306 |
307 local first, last; | 307 local first, last; |
308 for key, item, when in iter do | 308 for archive_id, item, when in iter do |
309 local body_tag = item:get_child("body"); | 309 local body_tag = item:get_child("body"); |
310 local body = body_tag and body_tag:get_text(); | 310 local body = body_tag and body_tag:get_text(); |
311 local subject = item:get_child_text("subject"); | 311 local subject = item:get_child_text("subject"); |
312 local verb = nil; | 312 local verb = nil; |
313 local lang = body_tag and body_tag.attr["xml:lang"] or item.attr["xml:lang"]; | 313 local lang = body_tag and body_tag.attr["xml:lang"] or item.attr["xml:lang"]; |
346 -- XEP-0308: Last Message Correction | 346 -- XEP-0308: Last Message Correction |
347 local edit = item:find("{urn:xmpp:message-correct:0}replace/@id"); | 347 local edit = item:find("{urn:xmpp:message-correct:0}replace/@id"); |
348 if edit then | 348 if edit then |
349 local found = false; | 349 local found = false; |
350 for n = i-1, 1, -1 do | 350 for n = i-1, 1, -1 do |
351 if logs[n].id == edit and nick == logs[n].nick then | 351 if logs[n].message_id == edit and nick == logs[n].nick then |
352 found = true; | 352 found = true; |
353 logs[n].edited = key; | 353 logs[n].edited = archive_id; |
354 edit = logs[n].key; | 354 edit = logs[n].archive_id; |
355 break; | 355 break; |
356 end | 356 end |
357 end | 357 end |
358 if not found then | 358 if not found then |
359 -- Ignore unresolved edit. | 359 -- Ignore unresolved edit. |
365 local reactions = item:get_child("reactions", "urn:xmpp:reactions:0"); | 365 local reactions = item:get_child("reactions", "urn:xmpp:reactions:0"); |
366 if reactions then | 366 if reactions then |
367 -- COMPAT Movim uses an @to attribute instead of the correct @id | 367 -- COMPAT Movim uses an @to attribute instead of the correct @id |
368 local target_id = reactions.attr.id or reactions.attr.to; | 368 local target_id = reactions.attr.id or reactions.attr.to; |
369 for n = i - 1, 1, -1 do | 369 for n = i - 1, 1, -1 do |
370 if logs[n].key == target_id then | 370 if logs[n].archive_id == target_id then |
371 local react_map = logs[n].reactions; -- { string : integer } | 371 local react_map = logs[n].reactions; -- { string : integer } |
372 if not react_map then | 372 if not react_map then |
373 react_map = {}; | 373 react_map = {}; |
374 logs[n].reactions = react_map; | 374 logs[n].reactions = react_map; |
375 end | 375 end |
387 -- XEP-0461: Message Replies | 387 -- XEP-0461: Message Replies |
388 local reply = item:get_child("reply", "urn:xmpp:reply:0"); | 388 local reply = item:get_child("reply", "urn:xmpp:reply:0"); |
389 | 389 |
390 if body or verb or oob then | 390 if body or verb or oob then |
391 local line = { | 391 local line = { |
392 id = item.attr.id, | 392 message_id = item.attr.id; |
393 key = key; | 393 archive_id = archive_id; |
394 datetime = datetime.datetime(when); | 394 datetime = datetime.datetime(when); |
395 time = datetime.time(when); | 395 time = datetime.time(when); |
396 verb = verb; | 396 verb = verb; |
397 body = body; | 397 body = body; |
398 lang = lang; | 398 lang = lang; |
399 nick = nick; | 399 nick = nick; |
400 st_name = item.name; | 400 st_name = item.name; |
401 st_type = item.attr.type; | 401 st_type = item.attr.type; |
402 edit = edit; | 402 edit = edit; |
403 reply = reply and reply.attr.id; | 403 reply = reply and reply.attr.id; |
404 -- COMPAT | |
405 key = archive_id; | |
404 }; | 406 }; |
405 if oob then | 407 if oob then |
406 line.oob = { | 408 line.oob = { |
407 url = oob:get_child_text("url"); | 409 url = oob:get_child_text("url"); |
408 desc = oob:get_child_text("desc"); | 410 desc = oob:get_child_text("desc"); |
409 } | 411 } |
410 end | 412 end |
411 logs[i], i = line, i + 1; | 413 logs[i], i = line, i + 1; |
412 end | 414 end |
413 | 415 |
414 first = first or key; | 416 first = first or archive_id; |
415 last = key; | 417 last = archive_id; |
416 end | 418 end |
417 if i == 1 and not lazy then return end -- No items | 419 if i == 1 and not lazy then return end -- No items |
418 | 420 |
419 local next_when, prev_when = "", ""; | 421 local next_when, prev_when = "", ""; |
420 local date_list = archive.dates and archive:dates(room); | 422 local date_list = archive.dates and archive:dates(room); |