diff libervia/server/restricted_bridge.py @ 1350:a32f3f47e4a8

server (restricted_bridge): added `interestsRegisterFileSharing` + filter extra_s in `FISInvite`
author Goffi <goffi@goffi.org>
date Sat, 05 Sep 2020 21:59:20 +0200
parents fe353fceec38
children 4c51f22a813a
line wrap: on
line diff
--- a/libervia/server/restricted_bridge.py	Sat Sep 05 21:59:17 2020 +0200
+++ b/libervia/server/restricted_bridge.py	Sat Sep 05 21:59:20 2020 +0200
@@ -17,6 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from libervia.server.constants import Const as C
+from sat.tools.common import data_format
 
 
 class RestrictedBridge:
@@ -56,6 +57,22 @@
         return await self.host.bridgeCall(
             "fileSharingDelete", service_jid, path, namespace, profile)
 
+    async def interestsRegisterFileSharing(
+        self, service, repos_type, namespace, path, name, extra_s, profile
+    ):
+        if extra_s:
+            # we only allow "thumb_url" here
+            extra = data_format.deserialise(extra_s)
+            if "thumb_url" in extra:
+                extra_s = data_format.serialise({"thumb_url": extra["thumb_url"]})
+            else:
+                extra_s = ""
+
+        return await self.host.bridgeCall(
+            "interestsRegisterFileSharing", service, repos_type, namespace, path, name,
+            extra_s, profile
+        )
+
     async def interestRetract(
         self, service_jid, item_id, profile
     ):
@@ -66,6 +83,14 @@
         self, invitee_jid_s, service_s, repos_type, namespace, path, name, extra_s,
         profile
     ):
+        if extra_s:
+            # we only allow "thumb_url" here
+            extra = data_format.deserialise(extra_s)
+            if "thumb_url" in extra:
+                extra_s = data_format.serialise({"thumb_url": extra["thumb_url"]})
+            else:
+                extra_s = ""
+
         return await self.host.bridgeCall(
             "FISInvite", invitee_jid_s, service_s, repos_type, namespace, path, name,
             extra_s, profile