core (memory/encryption): encryption session are now restored on client connection

This commit is contained in:
Goffi 2020-03-22 18:39:12 +01:00
commit 900daa7ad9

View file

@ -169,12 +169,12 @@ class Context(potr.context.Context):
feedback = _("/!\\ conversation with %(other_jid)s is now UNENCRYPTED") % {
"other_jid": self.peer.full()
}
d = client.encryption.stop(self.peer, NS_OTR)
d = defer.ensureDeferred(client.encryption.stop(self.peer, NS_OTR))
d.addCallback(self.stopCb, feedback=feedback)
d.addErrback(self.stopEb)
return
elif state == potr.context.STATE_ENCRYPTED:
client.encryption.start(self.peer, NS_OTR)
defer.ensureDeferred(client.encryption.start(self.peer, NS_OTR))
try:
trusted = self.isTrusted()
except TypeError:
@ -201,7 +201,7 @@ class Context(potr.context.Context):
feedback = D_("OTR conversation with {other_jid} is FINISHED").format(
other_jid=self.peer.full()
)
d = client.encryption.stop(self.peer, NS_OTR)
d = defer.ensureDeferred(client.encryption.stop(self.peer, NS_OTR))
d.addCallback(self.stopCb, feedback=feedback)
d.addErrback(self.stopEb)
return
@ -808,7 +808,7 @@ class OTR(object):
otrctx = client._otr_context_manager.getContextForUser(to_jid)
if otrctx.state != potr.context.STATE_PLAINTEXT:
client.encryption.start(to_jid, NS_OTR)
defer.ensureDeferred(client.encryption.start(to_jid, NS_OTR))
client.encryption.setEncryptionFlag(mess_data)
if not mess_data["to"].resource:
# if not resource was given, we force it here