changeset 2859:4e875d9eea48

plugin XEP-0384: give feedback to client when encryption failed
author Goffi <goffi@goffi.org>
date Wed, 20 Mar 2019 09:08:47 +0100
parents 31a5038cdf79
children 851c47cc4ae7
files sat/core/constants.py sat/plugins/plugin_xep_0384.py
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sat/core/constants.py	Wed Mar 20 09:08:47 2019 +0100
+++ b/sat/core/constants.py	Wed Mar 20 09:08:47 2019 +0100
@@ -123,6 +123,7 @@
 
     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"
--- a/sat/plugins/plugin_xep_0384.py	Wed Mar 20 09:08:47 2019 +0100
+++ b/sat/plugins/plugin_xep_0384.py	Wed Mar 20 09:08:47 2019 +0100
@@ -891,9 +891,11 @@
                 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)