From 02f140614fd580a1cc1265e5197a4d470528a02a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 19 Nov 2018 22:10:41 +0100 Subject: [PATCH] xep_0384: use exception instead of log when missing own key when decrypting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- plugin.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 5a13190..45e761a 100644 --- a/plugin.py +++ b/plugin.py @@ -69,6 +69,13 @@ def _load_device_id(cache_dir: str) -> int: class PluginCouldNotLoad(Exception): pass +# Generic exception +class XEP0384(Exception): pass + + +class MissingOwnKey(XEP0384): pass + + class XEP_0384(BasePlugin): """ @@ -233,8 +240,7 @@ class XEP_0384(BasePlugin): key = header.xml.find("{%s}key[@rid='%s']" % ( OMEMO_BASE_NS, self._device_id)) if key is None: - log.debug("Saw encrypted message that wasn't for me, ignoring.") - return None + raise MissingOwnKey("Encrypted message is not for us") key = Key(key) isPrekeyMessage = key['prekey'] in TRUE_VALUES