Fix InvalidParameterError handling
This commit is contained in:
parent
7bbff365ad
commit
12659472b0
5
otr.py
5
otr.py
|
@ -147,7 +147,8 @@ class OTR(context.Account):
|
||||||
text, tlvs = channel.receiveMessage(msgtxt.encode(),appdata=stanza.getThread()) or b''
|
text, tlvs = channel.receiveMessage(msgtxt.encode(),appdata=stanza.getThread()) or b''
|
||||||
except (context.UnencryptedMessage,context.NotEncryptedError,context.ErrorReceived,crypt.InvalidParameterError) as e:
|
except (context.UnencryptedMessage,context.NotEncryptedError,context.ErrorReceived,crypt.InvalidParameterError) as e:
|
||||||
self.log.error("** got exception while decrypting message: %s" % e)
|
self.log.error("** got exception while decrypting message: %s" % e)
|
||||||
channel.printl(OTR.STATUS[e].format(msg=msgtxt,err=e.args[0].error))
|
status = OTR.STATUS[e.__class__]
|
||||||
|
channel.printl(status.format(msg=msgtxt,err=e.args[0].error) if len(e.args) > 0 and hasattr(e.args[0], 'error') else status)
|
||||||
else:
|
else:
|
||||||
channel.resource = sFrom.resource
|
channel.resource = sFrom.resource
|
||||||
stanza.setBody(text and text.decode() or "")
|
stanza.setBody(text and text.decode() or "")
|
||||||
|
@ -169,7 +170,7 @@ class OTR(context.Account):
|
||||||
message = (encrypted != self.getDefaultQueryMessage(OTR.DEFAULT_POLICY.get)) and event.message or ""
|
message = (encrypted != self.getDefaultQueryMessage(OTR.DEFAULT_POLICY.get)) and event.message or ""
|
||||||
except context.NotEncryptedError as e:
|
except context.NotEncryptedError as e:
|
||||||
self.log.error("** got exception while encrypting message: %s" % e)
|
self.log.error("** got exception while encrypting message: %s" % e)
|
||||||
channel.printl(peer,OTR.STATUS[e])
|
channel.printl(peer,OTR.STATUS[e.__class__])
|
||||||
else:
|
else:
|
||||||
event.msg_iq.setBody(encrypted.decode()) # encrypted data goes here
|
event.msg_iq.setBody(encrypted.decode()) # encrypted data goes here
|
||||||
event.message = message # message that will be displayed in our chat goes here
|
event.message = message # message that will be displayed in our chat goes here
|
||||||
|
|
|
@ -17,5 +17,5 @@
|
||||||
"gajim>=1.6,<1.9"
|
"gajim>=1.6,<1.9"
|
||||||
],
|
],
|
||||||
"short_name": "otrplugin",
|
"short_name": "otrplugin",
|
||||||
"version": "0.5.2"
|
"version": "0.5.3"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue