diff sat/plugins/plugin_xep_0329.py @ 3040:fee60f17ebac

jp: jp asyncio port: /!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\ This patch implements the port of jp to asyncio, so it is now correctly using the bridge asynchronously, and it can be used with bridges like `pb`. This also simplify the code, notably for things which were previously implemented with many callbacks (like pagination with RSM). During the process, some behaviours have been modified/fixed, in jp and backends, check diff for details.
author Goffi <goffi@goffi.org>
date Wed, 25 Sep 2019 08:56:41 +0200
parents 95e2fd14a761
children 02492db1ce39
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0329.py	Wed Sep 25 08:53:38 2019 +0200
+++ b/sat/plugins/plugin_xep_0329.py	Wed Sep 25 08:56:41 2019 +0200
@@ -595,10 +595,14 @@
         ):
             return
         for file_data in files_data:
-            file_elt = self._jf.buildFileElementFromDict(
-                file_data, modified=file_data.get("modified", file_data["created"])
-            )
-            query_elt.addChild(file_elt)
+            if file_data['type'] == C.FILE_TYPE_DIRECTORY:
+                directory_elt = query_elt.addElement("directory")
+                directory_elt['name'] = file_data['name']
+            else:
+                file_elt = self._jf.buildFileElementFromDict(
+                    file_data, modified=file_data.get("modified", file_data["created"])
+                )
+                query_elt.addChild(file_elt)
         client.send(iq_result_elt)
 
     def onComponentRequest(self, iq_elt, client):
@@ -624,7 +628,7 @@
                 file_data = {"name": elt["name"], "type": C.FILE_TYPE_DIRECTORY}
             else:
                 log.warning(
-                    _("unexpected element, ignoring: {elt}").format(elt=elt.toXml())
+                    _(f"unexpected element, ignoring: {elt.toXml()}")
                 )
                 continue
             files.append(file_data)
@@ -642,7 +646,7 @@
 
     def _listFiles(self, target_jid, path, extra, profile):
         client = self.host.getClient(profile)
-        target_jid = client.jid.userhostJID() if not target_jid else jid.JID(target_jid)
+        target_jid = client.jid if not target_jid else jid.JID(target_jid)
         d = self.listFiles(client, target_jid, path or None)
         d.addCallback(self._serializeData)
         return d