From e89135b8aec85af6639d328bf5ba373861102ddc Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 20 Mar 2019 09:08:47 +0100 Subject: [PATCH] plugin XEP-0384: give feedback to client when encryption failed --- sat/core/constants.py | 1 + sat/plugins/plugin_xep_0384.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sat/core/constants.py b/sat/core/constants.py index e2e25a28..28a6346e 100644 --- a/sat/core/constants.py +++ b/sat/core/constants.py @@ -123,6 +123,7 @@ class Const(object): MESS_EXTRA_INFO = u"info_type" EXTRA_INFO_DECR_ERR = u"DECRYPTION_ERROR" + EXTRA_INFO_ENCR_ERR = u"ENCRYPTION_ERROR" # encryption is a key for plugins MESS_KEY_ENCRYPTION = u"ENCRYPTION" diff --git a/sat/plugins/plugin_xep_0384.py b/sat/plugins/plugin_xep_0384.py index a2639549..7b6a23a4 100644 --- a/sat/plugins/plugin_xep_0384.py +++ b/sat/plugins/plugin_xep_0384.py @@ -891,9 +891,11 @@ class OMEMO(object): else: break except Exception as e: - log.warning( - _(u"Can't encrypt message for {entity}: {reason}".format( - entity=entity_bare_jid.full(), reason=str(e).decode('utf-8', 'replace')))) + msg = _(u"Can't encrypt message for {entity}: {reason}".format( + entity=entity_bare_jid.full(), reason=str(e).decode('utf-8', 'replace'))) + log.warning(msg) + extra = {C.MESS_EXTRA_INFO: C.EXTRA_INFO_ENCR_ERR} + client.feedback(entity_bare_jid, msg, extra) raise e defer.returnValue(encrypted)