Mercurial > libervia-backend
changeset 2130:f0bc29dc8157
added "send" trigger point as the last one before sending, can be used for e2e encryption
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 04 Feb 2017 17:59:15 +0100 |
parents | 6a66c8c5a567 |
children | 628c1c95f442 |
files | src/core/xmpp.py |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/xmpp.py Sat Feb 04 17:59:13 2017 +0100 +++ b/src/core/xmpp.py Sat Feb 04 17:59:15 2017 +0100 @@ -25,6 +25,7 @@ from twisted.words.protocols.jabber import xmlstream from twisted.words.protocols.jabber import error from twisted.words.protocols.jabber import jid +from twisted.words.xish import domish from twisted.python import failure from wokkel import client as wokkel_client, disco, xmppim, generic, iwokkel from wokkel import delay @@ -93,6 +94,21 @@ iq_error_elt = error.StanzaError(condition).toResponse(iq_elt) self.xmlstream.send(iq_error_elt) + def send(self, obj): + # original send method accept string + # but we restrict to domish.Element to make trigger treatments easier + assert isinstance(obj, domish.Element) + # XXX: this trigger is the last one before sending stanza on wire + # is it is intended for things like end 2 end encryption. + # *DO NOT* cancel (i.e. return False) without very good reason + # (out of band transmission for instance). + # e2e should have a priority of 0 here, and out of band transmission + # a lower priority + if not self.host_app.trigger.point("send", self, obj): + return + return super(SatXMPPClient, self).send(obj) + + def _authd(self, xmlstream): if not self.host_app.trigger.point("XML Initialized", xmlstream, self.profile): return