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
This commit is contained in:
Goffi 2017-02-05 15:00:01 +01:00
commit aeeb0c5635

View file

@ -652,7 +652,7 @@ class SAT(service.Service):
pre_xml_treatments.addCallback(lambda dummy: self.generateMessageXML(data))
pre_xml_treatments.chainDeferred(post_xml_treatments)
post_xml_treatments.addCallback(self.messageSendToStream, client)
post_xml_treatments.addCallback(client.sendMessage)
if send_only:
log.debug(_("Triggers, storage and echo have been inhibited by the 'send_only' parameter"))
else:
@ -666,15 +666,6 @@ class SAT(service.Service):
"""A message sending can be cancelled by a plugin treatment"""
failure.trap(exceptions.CancelError)
def messageSendToStream(self, data, client):
"""Actualy send the message to the server
@param data: message data dictionnary
@param client: profile's client
"""
client.send(data[u'xml'])
return data
def messageAddToHistory(self, data, client):
"""Store message into database (for local history)