plugin OTR: fixes handling of the FINISHED state
This commit is contained in:
parent
b294272020
commit
f2d630fcad
1 changed files with 15 additions and 5 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue