From 97d29bc1cdb66f3f3c8f0a66acb124ee62e190b0 Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 23 Aug 2019 12:51:19 +0200 Subject: [PATCH] Fix potential race condition when encrypting (do not try to rely on the current tab) --- poezio/plugin_e2ee.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py index ab644f7a..b18aae3b 100644 --- a/poezio/plugin_e2ee.py +++ b/poezio/plugin_e2ee.py @@ -21,7 +21,14 @@ from typing import ( from slixmpp import InvalidJID, JID, Message from slixmpp.xmlstream import StanzaBase -from poezio.tabs import ConversationTab, DynamicConversationTab, StaticConversationTab, PrivateTab, MucTab +from poezio.tabs import ( + ChatTab, + ConversationTab, + DynamicConversationTab, + MucTab, + PrivateTab, + StaticConversationTab, +) from poezio.plugin import BasePlugin from asyncio import iscoroutinefunction @@ -222,8 +229,8 @@ class E2EEPlugin(BasePlugin): return stanza message = stanza - tab = self.api.current_tab() - jid = tab.jid + jid = stanza['to'] + tab = self.core.tabs.by_name_and_class(jid, ChatTab) if not self._encryption_enabled(jid): return message