plugin OTR: fixes handling of the FINISHED state

This commit is contained in:
souliane 2014-09-05 10:39:06 +02:00
commit f2d630fcad

View file

@ -427,11 +427,21 @@ class OTR(object):
if mess_data['type'] != 'groupchat' and not to_jid.resource:
to_jid.resource = self.host.memory.getLastResource(to_jid, profile) # FIXME: it's dirty, but frontends don't manage resources correctly now, refactoring is planed
otrctx = self.context_managers[profile].getContextForUser(to_jid)
if mess_data['type'] != 'groupchat' and otrctx.state == potr.context.STATE_ENCRYPTED:
log.debug(u"encrypting message")
otrctx.sendMessage(0, mess_data['message'].encode('utf-8'))
client = self.host.getClient(profile)
self.host.sendMessageToBridge(mess_data, client)
if mess_data['type'] != 'groupchat' and otrctx.state != potr.context.STATE_PLAINTEXT:
if otrctx.state == potr.context.STATE_ENCRYPTED:
log.debug(u"encrypting message")
otrctx.sendMessage(0, mess_data['message'].encode('utf-8'))
client = self.host.getClient(profile)
self.host.sendMessageToBridge(mess_data, client)
else:
feedback = D_("Your message was not sent because your correspondent closed the encrypted conversation on his/her side. Either close your own side, or refresh the session.")
client = self.host.getClient(profile)
self.host.bridge.newMessage(to_jid.full(),
feedback,
mess_type="headline",
to_jid=client.jid.full(),
extra={},
profile=client.profile)
return False
else:
log.debug(u"sending message unencrypted")