Mercurial > libervia-web
diff src/browser/sat_browser/plugin_sec_otr.py @ 537:cd492c18b366
browser_side (plugin OTR): manage the plain text messages ourselves rather than leaving it to otr.js
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 07 Sep 2014 19:28:27 +0200 |
parents | 048ae7314156 |
children | 3317e5d0ac1d |
line wrap: on
line diff
--- a/src/browser/sat_browser/plugin_sec_otr.py Sun Sep 07 16:40:33 2014 +0200 +++ b/src/browser/sat_browser/plugin_sec_otr.py Sun Sep 07 19:28:27 2014 +0200 @@ -50,6 +50,8 @@ 'ALLOW_V2': True, 'ALLOW_V3': True, 'REQUIRE_ENCRYPTION': False, + 'SEND_WHITESPACE_TAG': False, + 'WHITESPACE_START_AKE': False } # list a couple of texts (untrusted, trusted) for each state @@ -92,6 +94,8 @@ def receiveMessageCb(self, msg, encrypted): assert isinstance(self.peer, jid.JID) + if not encrypted: + log.warning("A plain-text message has been handled by otr.js") log.debug("message received (was %s): %s" % ('encrypted' if encrypted else 'plain', msg)) if not encrypted: if self.state == otr.context.STATE_ENCRYPTED: @@ -348,13 +352,17 @@ def messageReceivedTrigger(self, from_jid, msg, msg_type, to_jid, extra): if msg_type == C.MESS_TYPE_INFO: return True - other_jid = to_jid if from_jid.bare == self.host.whoami.bare else from_jid + + tag = otr.proto.checkForOTR(msg) + if tag is None or (tag == otr.context.WHITESPACE_TAG and not DEFAULT_POLICY_FLAGS['WHITESPACE_START_AKE']): + return True # TODO: signal the user that the contact wants to speak OTR def cb(jid): otrctx = self.context_manager.getContextForUser(jid) otrctx.receiveMessage(msg) return False # interrupt the main process + other_jid = to_jid if from_jid.bare == self.host.whoami.bare else from_jid self.fixResource(other_jid, cb) def sendMessageTrigger(self, to_jid, msg, msg_type, extra):