diff libervia/backend/core/main.py @ 4306:94e0968987cd

plugin XEP-0033: code modernisation, improve delivery, data validation: - Code has been rewritten using Pydantic models and `async` coroutines for data validation and cleaner element parsing/generation. - Delivery has been completely rewritten. It now works even if server doesn't support multicast, and send to local multicast service first. Delivering to local multicast service first is due to bad support of XEP-0033 in server (notably Prosody which has an incomplete implementation), and the current impossibility to detect if a sub-domain service handles fully multicast or only for local domains. This is a workaround to have a good balance between backward compatilibity and use of bandwith, and to make it work with the incoming email gateway implementation (the gateway will only deliver to entities of its own domain). - disco feature checking now uses `async` corountines. `host` implementation still use Deferred return values for compatibility with legacy code. rel 450
author Goffi <goffi@goffi.org>
date Thu, 26 Sep 2024 16:12:01 +0200
parents 3a550e9a2b55
children
line wrap: on
line diff
--- a/libervia/backend/core/main.py	Thu Sep 26 16:11:56 2024 +0200
+++ b/libervia/backend/core/main.py	Thu Sep 26 16:12:01 2024 +0200
@@ -1167,13 +1167,13 @@
     # the main difference with client.disco is that self.memory.disco manage cache
 
     def hasFeature(self, *args, **kwargs):
-        return self.memory.disco.hasFeature(*args, **kwargs)
+        return defer.ensureDeferred(self.memory.disco.has_feature(*args, **kwargs))
 
     def check_feature(self, *args, **kwargs):
-        return self.memory.disco.check_feature(*args, **kwargs)
+        return defer.ensureDeferred(self.memory.disco.check_feature(*args, **kwargs))
 
     def check_features(self, *args, **kwargs):
-        return self.memory.disco.check_features(*args, **kwargs)
+        return defer.ensureDeferred(self.memory.disco.check_features(*args, **kwargs))
 
     def has_identity(self, *args, **kwargs):
         return self.memory.disco.has_identity(*args, **kwargs)
@@ -1190,8 +1190,8 @@
     def find_service_entities(self, *args, **kwargs):
         return self.memory.disco.find_service_entities(*args, **kwargs)
 
-    def find_features_set(self, *args, **kwargs):
-        return self.memory.disco.find_features_set(*args, **kwargs)
+    async def find_features_set(self, *args, **kwargs):
+        return await self.memory.disco.find_features_set(*args, **kwargs)
 
     def _find_by_features(
         self,
@@ -1266,7 +1266,7 @@
         found_own = {}
         found_roster = {}
         if service:
-            services_jids = await self.find_features_set(client, namespaces)
+            services_jids = await self.memory.disco.find_features_set(client, namespaces)
             services_jids = list(services_jids)  # we need a list to map results below
             services_infos = await defer.DeferredList(
                 [