comparison mod_smacks/mod_smacks.lua @ 3968:bf5d91769f99

Merge commit
author tmolitor <thilo@eightysoft.de>
date Sun, 05 Apr 2020 23:39:08 +0200
parents 0957ba6aeb99 ebc1f1d962c5
children effe2d93a59c
comparison
equal deleted inserted replaced
3967:0957ba6aeb99 3968:bf5d91769f99
15 local dep = require "util.dependencies"; 15 local dep = require "util.dependencies";
16 local cache = dep.softreq("util.cache"); -- only available in prosody 0.10+ 16 local cache = dep.softreq("util.cache"); -- only available in prosody 0.10+
17 local uuid_generate = require "util.uuid".generate; 17 local uuid_generate = require "util.uuid".generate;
18 local jid = require "util.jid"; 18 local jid = require "util.jid";
19 19
20 local t_insert, t_remove = table.insert, table.remove; 20 local t_remove = table.remove;
21 local math_min = math.min; 21 local math_min = math.min;
22 local math_max = math.max; 22 local math_max = math.max;
23 local os_time = os.time; 23 local os_time = os.time;
24 local tonumber, tostring = tonumber, tostring; 24 local tonumber, tostring = tonumber, tostring;
25 local add_filter = require "util.filters".add_filter; 25 local add_filter = require "util.filters".add_filter;
198 delayed_ack_function(session); 198 delayed_ack_function(session);
199 end 199 end
200 end 200 end
201 201
202 local function outgoing_stanza_filter(stanza, session) 202 local function outgoing_stanza_filter(stanza, session)
203 local is_stanza = stanza.attr and not stanza.attr.xmlns and not stanza.name:find":"; 203 -- XXX: Normally you wouldn't have to check the xmlns for a stanza as it's
204 if is_stanza and not stanza._cached then -- Stanza in default stream namespace 204 -- supposed to be nil.
205 -- However, when using mod_smacks with mod_websocket, then mod_websocket's
206 -- stanzas/out filter can get called before this one and adds the xmlns.
207 local is_stanza = stanza.attr and
208 (not stanza.attr.xmlns or stanza.attr.xmlns == 'jabber:client')
209 and not stanza.name:find":";
210
211 if is_stanza and not stanza._cached then
205 local queue = session.outgoing_stanza_queue; 212 local queue = session.outgoing_stanza_queue;
206 local cached_stanza = st.clone(stanza); 213 local cached_stanza = st.clone(stanza);
207 cached_stanza._cached = true; 214 cached_stanza._cached = true;
208 215
209 if cached_stanza and cached_stanza.name ~= "iq" and cached_stanza:get_child("delay", xmlns_delay) == nil then 216 if cached_stanza and cached_stanza.name ~= "iq" and cached_stanza:get_child("delay", xmlns_delay) == nil then