changeset 2137:410e7a940a8b

plugin XEP-0297: used sendMessage in forward, and added comment/warning: this method need to be checked as it is not used currently, and it may need better integration in the current message sending workflow
author Goffi <goffi@goffi.org>
date Sun, 05 Feb 2017 14:55:56 +0100
parents cc3a6aea9508
children 6e509ee853a8
files src/plugins/plugin_xep_0297.py
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0297.py	Sun Feb 05 14:55:54 2017 +0100
+++ b/src/plugins/plugin_xep_0297.py	Sun Feb 05 14:55:56 2017 +0100
@@ -19,7 +19,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.constants import Const as C
-from sat.core.i18n import _
+from sat.core.i18n import _, D_
 from sat.core.log import getLogger
 log = getLogger(__name__)
 
@@ -35,17 +35,18 @@
 NS_SF = C.NS_FORWARD
 
 PLUGIN_INFO = {
-    "name": "Stanza Forwarding",
-    "import_name": "XEP-0297",
-    "type": "XEP",
-    "protocols": ["XEP-0297"],
-    "main": "XEP_0297",
-    "handler": "yes",
-    "description": _("""Implementation of Stanza Forwarding""")
+    u"name": u"Stanza Forwarding",
+    u"import_name": u"XEP-0297",
+    u"type": u"XEP",
+    u"protocols": [u"XEP-0297"],
+    u"main": "XEP_0297",
+    u"handler": u"yes",
+    u"description": D_(u"""Implementation of Stanza Forwarding""")
 }
 
 
 class XEP_0297(object):
+    # FIXME: check this implementation which doesn't seems to be used
 
     def __init__(self, host):
         log.info(_("Stanza Forwarding plugin initialization"))
@@ -79,6 +80,9 @@
         @param profile_key (unicode): %(doc_profile_key)s
         @return: a Deferred when the message has been sent
         """
+        # FIXME: this method is not used and doesn't use mess_data which should be used for client.sendMessage
+        #        should it be deprecated? A method constructing the element without sending it seems more natural
+        log.warning(u"THIS METHOD IS DEPRECATED") # FIXME: we use this warning until we check the method
         msg = domish.Element((None, 'message'))
         msg['to'] = to_jid.full()
         msg['type'] = stanza['type']
@@ -98,7 +102,7 @@
         msg.addChild(forwarded_elt)
 
         client = self.host.getClient(profile_key)
-        return client.send(msg.toXml())
+        return client.sendMessage({u'xml': msg})
 
 
 class XEP_0297_handler(XMPPHandler):