Software /
code /
prosody-modules
Comparison
mod_smacks/mod_smacks.lua @ 3984:4e5fde519116
mod_smacks: better logging for georg
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Mon, 20 Apr 2020 14:49:17 +0200 |
parent | 3983:effe2d93a59c |
child | 3985:c3e9caa29857 |
comparison
equal
deleted
inserted
replaced
3983:effe2d93a59c | 3984:4e5fde519116 |
---|---|
418 end | 418 end |
419 end | 419 end |
420 end | 420 end |
421 | 421 |
422 -- don't send delivery errors for messages which will be delivered by mam later on | 422 -- don't send delivery errors for messages which will be delivered by mam later on |
423 local function has_stanza_id(stanza, by_jid) | 423 local function get_stanza_id(stanza, by_jid) |
424 for tag in stanza:childtags("stanza-id", "urn:xmpp:sid:0") do | 424 for tag in stanza:childtags("stanza-id", "urn:xmpp:sid:0") do |
425 if tag.attr.by == by_jid and tag.attr.id then | 425 if tag.attr.by == by_jid then |
426 return true | 426 return tag.attr.id; |
427 end | 427 end |
428 end | 428 end |
429 return false; | 429 return null; |
430 | 430 |
431 end | 431 end |
432 module:hook("delivery/failure", function(event) | 432 module:hook("delivery/failure", function(event) |
433 local session, stanza = event.session, event.stanza; | 433 local session, stanza = event.session, event.stanza; |
434 -- Only deal with authenticated (c2s) sessions | 434 -- Only deal with authenticated (c2s) sessions |
435 if session.username then | 435 if session.username then |
436 if stanza.name == "message" and stanza.attr.xmlns == nil and | 436 if stanza.name == "message" and stanza.attr.xmlns == nil and |
437 ( stanza.attr.type == "chat" or ( stanza.attr.type or "normal" ) == "normal" ) then | 437 ( stanza.attr.type == "chat" or ( stanza.attr.type or "normal" ) == "normal" ) then |
438 -- do nothing here for normal messages and don't send out "message delivery errors", | 438 -- do nothing here for normal messages and don't send out "message delivery errors", |
439 -- because messages are already in MAM at this point (no need to frighten users) | 439 -- because messages are already in MAM at this point (no need to frighten users) |
440 if session.mam_requested and has_stanza_id(stanza, jid.bare(session.full_jid) then | 440 local stanza_id = get_stanza_id(stanza, jid.bare(session.full_jid)); |
441 session.log("debug", "mod_smacks delivery/failuere returning true for mam-handled stanza"); | 441 if session.mam_requested and stanza_id ~= nil then |
442 session.log("debug", "mod_smacks delivery/failuere returning true for mam-handled stanza: mam-archive-id=%s", tostring(stanza_id)); | |
442 return true; -- stanza handled, don't send an error | 443 return true; -- stanza handled, don't send an error |
443 end | 444 end |
444 -- store message in offline store, if this client does not use mam *and* was the last client online | 445 -- store message in offline store, if this client does not use mam *and* was the last client online |
445 local sessions = prosody.hosts[module.host].sessions[session.username] and | 446 local sessions = prosody.hosts[module.host].sessions[session.username] and |
446 prosody.hosts[module.host].sessions[session.username].sessions or nil; | 447 prosody.hosts[module.host].sessions[session.username].sessions or nil; |