Software /
code /
prosody-modules
Changeset
3955:017f60608fc8
mod_smacks: also count outgoing MAM messages
mod_smacks doesn't count outgoing MAM messages, which causes warnings in Prosody such as:
> The client says it handled 41 new stanzas, but we only sent 2
It seems mod_smacks is in the wrong here and that it's too strict in trying to determine what is a valid stanza to count.
In RFC6120:
> Definition of XML Stanza: An XML stanza is the basic unit of meaning
> in XMPP. A stanza is a first-level element (at depth=1 of the stream)
> whose element name is "message", "presence", or "iq" and whose
> qualifying namespace is 'jabber:client' or 'jabber:server'.
author | JC Brand <jc@opkode.com> |
---|---|
date | Thu, 26 Mar 2020 11:57:02 +0100 |
parents | 3954:7a2998e48545 |
children | 3956:ebc1f1d962c5 |
files | mod_smacks/mod_smacks.lua |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_smacks/mod_smacks.lua Wed Mar 25 19:42:18 2020 +0100 +++ b/mod_smacks/mod_smacks.lua Thu Mar 26 11:57:02 2020 +0100 @@ -17,7 +17,7 @@ local uuid_generate = require "util.uuid".generate; local jid = require "util.jid"; -local t_insert, t_remove = table.insert, table.remove; +local t_remove = table.remove; local math_min = math.min; local math_max = math.max; local os_time = os.time; @@ -199,9 +199,16 @@ end end +local function is_stanza(stanza) + return stanza.attr and + ( not stanza.attr.xmlns or + stanza.attr.xmlns == 'jabber:client' or + stanza.attr.xmlns == 'jabber:server' + ) and not stanza.name:find":"; +end + local function outgoing_stanza_filter(stanza, session) - local is_stanza = stanza.attr and not stanza.attr.xmlns and not stanza.name:find":"; - if is_stanza and not stanza._cached then -- Stanza in default stream namespace + if is_stanza(stanza) and not stanza._cached then local queue = session.outgoing_stanza_queue; local cached_stanza = st.clone(stanza); cached_stanza._cached = true; @@ -226,7 +233,7 @@ end local function count_incoming_stanzas(stanza, session) - if not stanza.attr.xmlns then + if is_stanza(stanza) then session.handled_stanza_count = session.handled_stanza_count + 1; session.log("debug", "Handled %d incoming stanzas", session.handled_stanza_count); end