Comparison

mod_push2/mod_push2.lua @ 6344:eb834f754f57 draft default tip

Merge update
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Fri, 18 Jul 2025 20:45:38 +0700
parent 6312:2488254c1bc2
comparison
equal deleted inserted replaced
6309:342f88e8d522 6344:eb834f754f57
149 -- urgent stanzas should be delivered without delay 149 -- urgent stanzas should be delivered without delay
150 local function is_voip(stanza) 150 local function is_voip(stanza)
151 if stanza.name == "message" then 151 if stanza.name == "message" then
152 if stanza:get_child("propose", "urn:xmpp:jingle-message:0") then 152 if stanza:get_child("propose", "urn:xmpp:jingle-message:0") then
153 return true, "jingle call" 153 return true, "jingle call"
154 end
155
156 if stanza:get_child("retract", "urn:xmpp:jingle-message:0") then
157 return true, "jingle call retract"
154 end 158 end
155 end 159 end
156 end 160 end
157 161
158 local function has_body(stanza) 162 local function has_body(stanza)
379 local to_user, to_host = jid.split(stanza.attr.to) 383 local to_user, to_host = jid.split(stanza.attr.to)
380 to_user = to_user or session.username 384 to_user = to_user or session.username
381 to_host = to_host or module.host 385 to_host = to_host or module.host
382 386
383 -- If another session has recent activity within configured grace period, don't send push 387 -- If another session has recent activity within configured grace period, don't send push
384 if does_match and match.grace and to_host == module.host and host_sessions[to_user] then 388 if does_match and match.grace and not is_voip(stanza) and to_host == module.host and host_sessions[to_user] then
385 local now = os_time() 389 local now = os_time()
386 for _, session in pairs(host_sessions[to_user].sessions) do 390 for _, session in pairs(host_sessions[to_user].sessions) do
387 if session.last_activity and session.push_registration_id ~= push_registration_id and (now - session.last_activity) < match.grace then 391 if session.last_activity and session.push_registration_id ~= push_registration_id and (now - session.last_activity) < match.grace then
388 does_match = false 392 does_match = false
389 end 393 end