aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-22 22:13:03 +0100
committerKim Alvefur <zash@zash.se>2021-12-22 22:13:03 +0100
commitecab94165d785e1426ad20b8d38a13e0daef147a (patch)
tree12ebaac1acbb075630d9d6ffaf0e903bd8606ed8 /plugins
parent6d8f1d56ed776eb03374a66410703c7d24be07a3 (diff)
downloadprosody-ecab94165d785e1426ad20b8d38a13e0daef147a.tar.gz
prosody-ecab94165d785e1426ad20b8d38a13e0daef147a.zip
mod_smacks: Compact code using new stanza API
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_smacks.lua11
1 files changed, 2 insertions, 9 deletions
diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua
index 677b69fc..4ec55025 100644
--- a/plugins/mod_smacks.lua
+++ b/plugins/mod_smacks.lua
@@ -376,14 +376,6 @@ end
-- don't send delivery errors for messages which will be delivered by mam later on
-- check if stanza was archived --> this will allow us to send back errors for stanzas not archived
-- because the user configured the server to do so ("no-archive"-setting for one special contact for example)
-local function get_stanza_id(stanza, by_jid)
- for tag in stanza:childtags("stanza-id", "urn:xmpp:sid:0") do
- if tag.attr.by == by_jid then
- return tag.attr.id;
- end
- end
- return nil;
-end
module:hook("delivery/failure", function(event)
local session, stanza = event.session, event.stanza;
-- Only deal with authenticated (c2s) sessions
@@ -397,7 +389,8 @@ module:hook("delivery/failure", function(event)
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));
+ local stanza_id = stanza:get_child_with_attr("stanza-id", "urn:xmpp:sid:0", "by", jid.bare(session.full_jid));
+ stanza_id = stanza_id and stanza_id.attr.id;
if session.mam_requested and stanza_id ~= nil then
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