plugin XEP-0384: give feedback to client when encryption failed

This commit is contained in:
Goffi 2019-03-20 09:08:47 +01:00
commit e89135b8ae
2 changed files with 6 additions and 3 deletions

View file

@ -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"

View file

@ -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)