plugin XEP-0384: give feedback to user when trust must be handled before sending a message

This commit is contained in:
Goffi 2019-01-05 14:15:11 +01:00
commit 70253cd205

View file

@ -823,9 +823,10 @@ class OMEMO(object):
## triggers
@defer.inlineCallbacks
def handleProblems(self, client, bundles, problems):
def handleProblems(self, client, entity, bundles, problems):
"""Try to solve problem found by EncryptMessage
@param entity(jid.JID): bare jid of the destinee
@param bundles(dict): bundles data as used in EncryptMessage
already filled with known bundles, missing bundles
need to be added to it
@ -851,6 +852,11 @@ class OMEMO(object):
'device': data.device,
'ik': data.ik}
user_msg = D_(u"Not all destination devices are trusted, we can't encrypt "
u"message in such a situation. Please indicate if you trust "
u"those devices or not in the trust manager before we can "
"send this message")
client.feedback(entity, user_msg)
xmlui = yield self.getTrustUI(client, trust_data=trust_data, submit_id=u"")
answer = yield xml_tools.deferXMLUI(
@ -898,7 +904,7 @@ class OMEMO(object):
bundles)
except omemo_excpt.EncryptionProblemsException as e:
# we know the problem to solve, we can try to fix them
expect_problems = yield self.handleProblems(client, bundles, e.problems)
expect_problems = yield self.handleProblems(client, entity_bare_jid, bundles, e.problems)
# and try an encryption again.
try:
encrypted = yield omemo_session.encryptMessage(