# HG changeset patch # User tmolitor # Date 1602518170 -7200 # Node ID 22e7b3d6fcaefaa5da05c22aacb7c07f58ae356e # Parent 4611999fd8d339907173cea06beaee4c1feb0b3a mod_smacks: don't store mam results in offline store diff -r 4611999fd8d3 -r 22e7b3d6fcae mod_smacks/mod_smacks.lua --- a/mod_smacks/mod_smacks.lua Mon Oct 12 13:21:16 2020 +0200 +++ b/mod_smacks/mod_smacks.lua Mon Oct 12 17:56:10 2020 +0200 @@ -26,6 +26,7 @@ local timer = require "util.timer"; local datetime = require "util.datetime"; +local xmlns_mam2 = "urn:xmpp:mam:2"; local xmlns_sm2 = "urn:xmpp:sm:2"; local xmlns_sm3 = "urn:xmpp:sm:3"; local xmlns_errors = "urn:ietf:params:xml:ns:xmpp-stanzas"; @@ -438,11 +439,16 @@ if session.username then if stanza.name == "message" and stanza.attr.xmlns == nil and ( stanza.attr.type == "chat" or ( stanza.attr.type or "normal" ) == "normal" ) then + -- don't store messages in offline store if they are mam results + local mam_result = stanza:get_child("result", xmlns_mam2); + if mam_result ~= nil then + return true; -- stanza already "handled", don't send an error and don't add it to offline storage + end -- do nothing here for normal messages and don't send out "message delivery errors", -- because messages are already in MAM at this point (no need to frighten users) local stanza_id = get_stanza_id(stanza, jid.bare(session.full_jid)); if session.mam_requested and stanza_id ~= nil then - session.log("debug", "mod_smacks delivery/failuere returning true for mam-handled stanza: mam-archive-id=%s", tostring(stanza_id)); + session.log("debug", "mod_smacks delivery/failure returning true for mam-handled stanza: mam-archive-id=%s", tostring(stanza_id)); return true; -- stanza handled, don't send an error end -- store message in offline store, if this client does not use mam *and* was the last client online @@ -451,7 +457,7 @@ if sessions and next(sessions) == session.resource and next(sessions, session.resource) == nil then local ok = module:fire_event("message/offline/handle", { origin = session, stanza = stanza } ); session.log("debug", "mod_smacks delivery/failuere returning %s for offline-handled stanza", tostring(ok)); - return ok; -- if stanza was handled, don't send an error + return ok; -- if stanza was handled, don't send an error end end end