diff sat/plugins/plugin_xep_0363.py @ 3293:f5a5aa9fa73a

plugin XEP-0363: fixed fileHTTPUploadGetSlot
author Goffi <goffi@goffi.org>
date Tue, 09 Jun 2020 05:58:57 +0200
parents 9057713ab124
children 6505e5cc6ab9
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0363.py	Mon Jun 08 08:54:53 2020 +0200
+++ b/sat/plugins/plugin_xep_0363.py	Tue Jun 09 05:58:57 2020 +0200
@@ -93,7 +93,7 @@
             "fileHTTPUploadGetSlot",
             ".plugin",
             in_sign="sisss",
-            out_sign="(ss)",
+            out_sign="(ssaa{ss})",
             method=self._getSlot,
             async_=True,
         )
@@ -272,15 +272,17 @@
         This method can be used when uploading is done by the frontend
         @param filename(unicode): name of the file to upload
         @param size(int): size of the file (must be non null)
-        @param upload_jid(jid.JID(), None, ''): HTTP upload capable entity
+        @param upload_jid(str, ''): HTTP upload capable entity
         @param content_type(unicode, None): MIME type of the content
             empty string or None to guess automatically
         """
         client = self.host.getClient(profile_key)
         filename = filename.replace("/", "_")
-        return defer.ensureDeferred(self.getSlot(
-            client, filename, size, content_type or None, upload_jid or None
+        d = defer.ensureDeferred(self.getSlot(
+            client, filename, size, content_type or None, jid.JID(upload_jid) or None
         ))
+        d.addCallback(lambda slot: (slot.get, slot.put, slot.headers))
+        return d
 
     async def getSlot(self, client, filename, size, content_type=None, upload_jid=None):
         """Get a slot (i.e. download/upload links)
@@ -304,7 +306,7 @@
             try:
                 upload_jid = client.http_upload_service
             except AttributeError:
-                found_entity = await self.getHTTPUploadEntity(profile=client.profile)
+                found_entity = await self.getHTTPUploadEntity(client)
                 return await self.getSlot(
                     client, filename, size, content_type, found_entity)
             else: