Skip to content

Commit 25abf88

Browse files
committed
Merge branch 'send-tag-message-hook' of https://github.com/mmb/pure-python-otr into mmb-send-tag-message-hook
2 parents 25524bd + d36b45a commit 25abf88

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ Install the potr Python module:
88

99
__Dependencies__: pycrypto >= 2.1 (see [dlitz/pycrypto](https://github.com/dlitz/pycrypto))
1010

11+
This software is experimental and potentially insecure. Do not rely on it
12+
=========================================================================
13+
1114
Usage Notes
1215
===========
1316
This module uses pycrypto's RNG. If you use this package in your application and your application
1417
uses `os.fork()`, make sure to call `Crypto.Random.atfork()` in both the parent and the child process.
1518

1619
Reporting bugs
1720
==============
18-
Please read the [FAQ](https://github.com/afflux/pure-python-otr/wiki) before submitting your
19-
issue to the [tracker](https://github.com/afflux/pure-python-otr/issues).
20-
21-
libotr SWIG bindings
22-
====================
23-
python-otr.pentabarf.de and pyotr.pentabarf.de redirect here.
24-
If you are still looking for the old C library bindings, they have moved
25-
to <http://python-otr-old.pentabarf.de/>
21+
Please read the [FAQ](https://github.com/python-otr/pure-python-otr/wiki) before submitting your
22+
issue to the [tracker](https://github.com/python-otr/pure-python-otr/issues).

src/potr/context.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def processOutgoingMessage(self, msg, flags, tlvs=[]):
282282
# TODO notify
283283
msg = self.user.getDefaultQueryMessage(self.getPolicy)
284284
return msg
285-
if self.getPolicy('SEND_TAG') and self.tagOffer != OFFER_REJECTED:
285+
if self.getPolicy('SEND_TAG') and \
286+
self.tagOffer != OFFER_REJECTED and \
287+
self.shouldTagMessage(msg):
286288
self.tagOffer = OFFER_SENT
287289
versions = set()
288290
if self.getPolicy('ALLOW_V1'):
@@ -492,6 +494,10 @@ def getExtraKey(self, extraKeyAppId=None, extraKeyAppData=None, appdata=None):
492494
self.sendInternal(b'', tlvs=tlvs, appdata=appdata)
493495
return self.crypto.extraKey
494496

497+
def shouldTagMessage(self, msg):
498+
"""Hook to decide whether to tag a message based on its contents."""
499+
return True
500+
495501
class Account(object):
496502
contextclass = Context
497503
def __init__(self, name, protocol, maxMessageSize, privkey=None):

0 commit comments

Comments
 (0)