Fix InvalidParameterError handling

This commit is contained in:
Bohdan Horbeshko 2024-05-25 23:18:22 +03:00
parent 7bbff365ad
commit 12659472b0
2 changed files with 4 additions and 3 deletions

5
otr.py
View file

@ -147,7 +147,8 @@ class OTR(context.Account):
text, tlvs = channel.receiveMessage(msgtxt.encode(),appdata=stanza.getThread()) or b''
except (context.UnencryptedMessage,context.NotEncryptedError,context.ErrorReceived,crypt.InvalidParameterError) as 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:
channel.resource = sFrom.resource
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 ""
except context.NotEncryptedError as 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:
event.msg_iq.setBody(encrypted.decode()) # encrypted data goes here
event.message = message # message that will be displayed in our chat goes here

View file

@ -17,5 +17,5 @@
"gajim>=1.6,<1.9"
],
"short_name": "otrplugin",
"version": "0.5.2"
"version": "0.5.3"
}