Przeglądaj źródła

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

factor2
damencho 1 rok temu
rodzic
commit
68f030bb7f
1 zmienionych plików z 13 dodań i 1 usunięć
  1. 13
    1
      resources/prosody-plugins/mod_muc_domain_mapper.lua

+ 13
- 1
resources/prosody-plugins/mod_muc_domain_mapper.lua Wyświetl plik

@@ -11,12 +11,14 @@ if not muc_domain_base then
11 11
     return
12 12
 end
13 13
 
14
+local log_not_allowed_errors = module:get_option_boolean('muc_mapper_log_not_allowed_errors', false);
15
+
14 16
 local util = module:require "util";
15 17
 local room_jid_match_rewrite = util.room_jid_match_rewrite;
16 18
 local internal_room_jid_match_rewrite = util.internal_room_jid_match_rewrite;
17 19
 
18 20
 -- We must filter stanzas in order to hook in to all incoming and outgoing messaging which skips the stanza routers
19
-function filter_stanza(stanza)
21
+function filter_stanza(stanza, session)
20 22
     if stanza.skipMapping then
21 23
         return stanza;
22 24
     end
@@ -36,6 +38,16 @@ function filter_stanza(stanza)
36 38
         if stanza.attr.from then
37 39
             stanza.attr.from = internal_room_jid_match_rewrite(stanza.attr.from, stanza)
38 40
         end
41
+
42
+        if log_not_allowed_errors and stanza.name == 'presence' and stanza.attr.type == 'error' then
43
+            local error = stanza:get_child('error');
44
+            if error and error.attr.type == 'cancel'
45
+                    and error:get_child('not-allowed', 'urn:ietf:params:xml:ns:xmpp-stanzas')
46
+                    and not session.jitsi_not_allowed_logged then
47
+                session.jitsi_not_allowed_logged = true;
48
+                session.log('error', 'Not allowed presence %s', stanza);
49
+            end
50
+        end
39 51
     end
40 52
     return stanza;
41 53
 end

Ładowanie…
Anuluj
Zapisz