mod_e2e_policy: Verify that the bare JID of stanza to and from is not in the whitelist
authorMichel Le Bihan <michel@lebihan.pl>
Fri, 30 Nov 2018 19:17:16 +0100
changeset 3389 762c7e7ee64b
parent 3388 4321c71cc535
child 3390 a76c420eca61
mod_e2e_policy: Verify that the bare JID of stanza to and from is not in the whitelist
mod_e2e_policy/mod_e2e_policy.lua
--- a/mod_e2e_policy/mod_e2e_policy.lua	Thu Nov 22 23:35:27 2018 +0000
+++ b/mod_e2e_policy/mod_e2e_policy.lua	Fri Nov 30 19:17:16 2018 +0100
@@ -1,4 +1,5 @@
 local st = require "util.stanza";
+local jid_bare = require "util.jid".bare;
 local host = module.host;
 local e2e_policy_chat = module:get_option_string("e2e_policy_chat", "optional"); -- possible values: none, optional and required
 local e2e_policy_muc = module:get_option_string("e2e_policy_muc", "optional"); -- possible values: none, optional and required
@@ -11,7 +12,7 @@
 
 function warn_on_plaintext_messages(event)
     -- check if JID is whitelisted
-    if e2e_policy_whitelist:contains(event.stanza.attr.from) or e2e_policy_whitelist:contains(event.stanza.attr.to) then
+    if e2e_policy_whitelist:contains(jid_bare(stanza.attr.from)) or e2e_policy_whitelist:contains(jid_bare(stanza.attr.to)) then
         return nil;
     end
     local body = event.stanza:get_child_text("body");