Explorar o código

Pass async=true for provisioning API list contacts

Tulir Asokan %!s(int64=3) %!d(string=hai) anos
pai
achega
4c405e2113
Modificáronse 2 ficheiros con 4 adicións e 3 borrados
  1. 3 2
      mausignald/signald.py
  2. 1 1
      mautrix_signal/web/provisioning_api.py

+ 3 - 2
mausignald/signald.py

@@ -326,8 +326,9 @@ class SignaldClient(SignaldRPCClient):
     async def remove_linked_device(self, username: str, device_id: int) -> None:
         await self.request_v1("remove_linked_device", account=username, deviceId=device_id)
 
-    async def list_contacts(self, username: str) -> list[Profile]:
-        resp = await self.request_v1("list_contacts", account=username)
+    async def list_contacts(self, username: str, use_cache: bool = False) -> list[Profile]:
+        kwargs = {"async": use_cache}
+        resp = await self.request_v1("list_contacts", account=username, **kwargs)
         return [Profile.deserialize(contact) for contact in resp["profiles"]]
 
     async def list_groups(self, username: str) -> list[Group | GroupV2]:

+ 1 - 1
mautrix_signal/web/provisioning_api.py

@@ -370,7 +370,7 @@ class ProvisioningAPI:
 
     async def list_contacts(self, request: web.Request) -> web.Response:
         user = await self.check_token_and_logged_in(request)
-        contacts = await self.bridge.signal.list_contacts(user.username)
+        contacts = await self.bridge.signal.list_contacts(user.username, use_cache=True)
         return web.json_response(
             {
                 c.address.number: {