comparison sat/plugins/plugin_sec_otr.py @ 3058:0408df45ebe7

plugin OTR: work around a bad exception raised in potr
author Goffi <goffi@goffi.org>
date Wed, 16 Oct 2019 08:39:52 +0200
parents fee60f17ebac
children 9d0df638c8b4
comparison
equal deleted inserted replaced
3057:f91d0e6d9b13 3058:0408df45ebe7
635 try: 635 try:
636 message = ( 636 message = (
637 next(iter(data["message"].values())) 637 next(iter(data["message"].values()))
638 ) # FIXME: Q&D fix for message refactoring, message is now a dict 638 ) # FIXME: Q&D fix for message refactoring, message is now a dict
639 res = otrctx.receiveMessage(message.encode("utf-8")) 639 res = otrctx.receiveMessage(message.encode("utf-8"))
640 except potr.context.UnencryptedMessage: 640 except (potr.context.UnencryptedMessage, potr.context.NotOTRMessage):
641 # potr has a bug with Python 3 and test message against str while bytes are
642 # expected, resulting in a NoOTRMessage raised instead of UnencryptedMessage;
643 # so we catch NotOTRMessage as a workaround
644 # TODO: report this upstream
641 encrypted = False 645 encrypted = False
642 if otrctx.state == potr.context.STATE_ENCRYPTED: 646 if otrctx.state == potr.context.STATE_ENCRYPTED:
643 log.warning( 647 log.warning(
644 "Received unencrypted message in an encrypted context (from {jid})" 648 "Received unencrypted message in an encrypted context (from {jid})"
645 .format(jid=from_jid.full()) 649 .format(jid=from_jid.full())