From f2d630fcad27c7b6c639eb8a18e3e09f8c06bed6 Mon Sep 17 00:00:00 2001 From: souliane Date: Fri, 5 Sep 2014 10:39:06 +0200 Subject: [PATCH] plugin OTR: fixes handling of the FINISHED state --- src/plugins/plugin_sec_otr.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/plugins/plugin_sec_otr.py b/src/plugins/plugin_sec_otr.py index 1269fd60..7b1abe21 100644 --- a/src/plugins/plugin_sec_otr.py +++ b/src/plugins/plugin_sec_otr.py @@ -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")