From 89b8cb33416939ed3c7a56741437e199f7d18713 Mon Sep 17 00:00:00 2001 From: Goffi Date: Sun, 5 Feb 2017 14:55:21 +0100 Subject: [PATCH] plugin XEP-0280: new setPrivate method to tell server not to carbon copy it. --- src/plugins/plugin_xep_0280.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/plugin_xep_0280.py b/src/plugins/plugin_xep_0280.py index ffdeb896..a8041876 100755 --- a/src/plugins/plugin_xep_0280.py +++ b/src/plugins/plugin_xep_0280.py @@ -39,14 +39,14 @@ PARAM_LABEL = D_(u"Message carbons") NS_CARBONS = 'urn:xmpp:carbons:2' PLUGIN_INFO = { - "name": "XEP-0280 Plugin", - "import_name": "XEP-0280", - "type": "XEP", - "protocols": ["XEP-0280"], + "name": u"XEP-0280 Plugin", + "import_name": u"XEP-0280", + "type": u"XEP", + "protocols": [u"XEP-0280"], "dependencies": [], - "main": "XEP_0280", - "handler": "yes", - "description": _("""Implementation of Message Carbons""") + "main": u"XEP_0280", + "handler": u"yes", + "description": D_(u"""Implementation of Message Carbons""") } @@ -79,6 +79,18 @@ class XEP_0280(object): def getHandler(self, profile): return XEP_0280_handler() + def setPrivate(self, message_elt): + """Add a element to a message + + this method is intented to be called on final domish.Element by other plugins + (in particular end 2 end encryption plugins) + @param message_elt(domish.Element): stanza + """ + if message_elt.name != u'message': + log.error(u"addPrivateElt must be used with stanzas") + return + message_elt.addElement((NS_CARBONS, u'private')) + @defer.inlineCallbacks def profileConnected(self, profile): """activate message carbons on connection if possible and activated in config"""