Mercurial > libervia-backend
comparison src/core/sat_main.py @ 2138:6e509ee853a8
plugin OTR, core; use of new sendMessage + OTR mini refactoring:
- new client.sendMessage method is used instead of sendMessageToStream
- client.feedback is used in OTR
- OTR now add message processing hints and carbon private element as recommanded by XEP-0364. Explicit Message Encryption is still TODO
- OTR use the new sendMessageFinish trigger, this has a number of advantages:
* there is little risk that OTR is skipped by other plugins (they have to use client.sendMessage as recommanded)
* being at the end of the chain, OTR can check and remove any HTML or other leaking elements
* OTR doesn't have to skip other plugins anymore, this means that things like delivery receipts are now working with OTR
(but because there is not full stanza encryption, they can leak metadata)
* OTR can decide to follow storage hint by letting or deleting "history" key
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 05 Feb 2017 15:00:01 +0100 |
parents | 628c1c95f442 |
children | be96beb7ca14 |
comparison
equal
deleted
inserted
replaced
2137:410e7a940a8b | 2138:6e509ee853a8 |
---|---|
650 | 650 |
651 log.debug(_(u"Sending message (type {type}, to {to})").format(type=data["type"], to=to_jid.full())) | 651 log.debug(_(u"Sending message (type {type}, to {to})").format(type=data["type"], to=to_jid.full())) |
652 | 652 |
653 pre_xml_treatments.addCallback(lambda dummy: self.generateMessageXML(data)) | 653 pre_xml_treatments.addCallback(lambda dummy: self.generateMessageXML(data)) |
654 pre_xml_treatments.chainDeferred(post_xml_treatments) | 654 pre_xml_treatments.chainDeferred(post_xml_treatments) |
655 post_xml_treatments.addCallback(self.messageSendToStream, client) | 655 post_xml_treatments.addCallback(client.sendMessage) |
656 if send_only: | 656 if send_only: |
657 log.debug(_("Triggers, storage and echo have been inhibited by the 'send_only' parameter")) | 657 log.debug(_("Triggers, storage and echo have been inhibited by the 'send_only' parameter")) |
658 else: | 658 else: |
659 post_xml_treatments.addCallback(self.messageAddToHistory, client) | 659 post_xml_treatments.addCallback(self.messageAddToHistory, client) |
660 post_xml_treatments.addCallback(self.messageSendToBridge, client) | 660 post_xml_treatments.addCallback(self.messageSendToBridge, client) |
663 return pre_xml_treatments | 663 return pre_xml_treatments |
664 | 664 |
665 def _cancelErrorTrap(self, failure): | 665 def _cancelErrorTrap(self, failure): |
666 """A message sending can be cancelled by a plugin treatment""" | 666 """A message sending can be cancelled by a plugin treatment""" |
667 failure.trap(exceptions.CancelError) | 667 failure.trap(exceptions.CancelError) |
668 | |
669 def messageSendToStream(self, data, client): | |
670 """Actualy send the message to the server | |
671 | |
672 @param data: message data dictionnary | |
673 @param client: profile's client | |
674 """ | |
675 client.send(data[u'xml']) | |
676 return data | |
677 | 668 |
678 def messageAddToHistory(self, data, client): | 669 def messageAddToHistory(self, data, client): |
679 """Store message into database (for local history) | 670 """Store message into database (for local history) |
680 | 671 |
681 @param data: message data dictionnary | 672 @param data: message data dictionnary |