summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-06-07 17:23:06 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2019-07-01 19:42:45 +0200
commitd1a3a35df6f5c866276469c204ca7b8d933f06cb (patch)
tree733dce27153bb015981ebcb803c39c0838a01c80
parent708ec2523d277678aa68d822749f7681c441b2d0 (diff)
downloadpoezio-d1a3a35df6f5c866276469c204ca7b8d933f06cb.tar.gz
poezio-d1a3a35df6f5c866276469c204ca7b8d933f06cb.tar.bz2
poezio-d1a3a35df6f5c866276469c204ca7b8d933f06cb.tar.xz
poezio-d1a3a35df6f5c866276469c204ca7b8d933f06cb.zip
e2ee api: Utilize priority in event handling
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
-rw-r--r--poezio/plugin_e2ee.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py
index e4497113..86b871fd 100644
--- a/poezio/plugin_e2ee.py
+++ b/poezio/plugin_e2ee.py
@@ -56,12 +56,17 @@ class E2EEPlugin(BasePlugin):
if self.encryption_short_name is None:
self.encryption_short_name = self.encryption_name
- self.api.add_event_handler('muc_msg', self._decrypt)
- self.api.add_event_handler('muc_say', self._encrypt)
- self.api.add_event_handler('conversation_msg', self._decrypt)
- self.api.add_event_handler('conversation_say', self._encrypt)
- self.api.add_event_handler('private_msg', self._decrypt)
- self.api.add_event_handler('private_say', self._encrypt)
+ # Ensure decryption is done before everything, so that other handlers
+ # don't have to know about the encryption mechanism.
+ self.api.add_event_handler('muc_msg', self._decrypt, priority=0)
+ self.api.add_event_handler('conversation_msg', self._decrypt, priority=0)
+ self.api.add_event_handler('private_msg', self._decrypt, priority=0)
+
+ # Ensure encryption is done after everything, so that whatever can be
+ # encrypted is encrypted, and no plain element slips in.
+ self.api.add_event_handler('muc_say', self._encrypt, priority=100)
+ self.api.add_event_handler('conversation_say', self._encrypt, priority=100)
+ self.api.add_event_handler('private_say', self._encrypt, priority=100)
for tab_t in (DynamicConversationTab, PrivateTab, MucTab):
self.api.add_tab_command(