feat: Adds option to print not-allowed errors we sent back to client.

This commit is contained in:
damencho
2024-04-11 10:19:14 -05:00
committed by Дамян Минков
parent 1c25a370be
commit 68f030bb7f

View File

@@ -11,12 +11,14 @@ if not muc_domain_base then
return
end
local log_not_allowed_errors = module:get_option_boolean('muc_mapper_log_not_allowed_errors', false);
local util = module:require "util";
local room_jid_match_rewrite = util.room_jid_match_rewrite;
local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;
-- We must filter stanzas in order to hook in to all incoming and outgoing messaging which skips the stanza routers
function filter_stanza(stanza)
function filter_stanza(stanza, session)
if stanza.skipMapping then
return stanza;
end
@@ -36,6 +38,16 @@ function filter_stanza(stanza)
if stanza.attr.from then
stanza.attr.from = internal_room_jid_match_rewrite(stanza.attr.from, stanza)
end
if log_not_allowed_errors and stanza.name == 'presence' and stanza.attr.type == 'error' then
local error = stanza:get_child('error');
if error and error.attr.type == 'cancel'
and error:get_child('not-allowed', 'urn:ietf:params:xml:ns:xmpp-stanzas')
and not session.jitsi_not_allowed_logged then
session.jitsi_not_allowed_logged = true;
session.log('error', 'Not allowed presence %s', stanza);
end
end
end
return stanza;
end