wip(sync): only open listen connections after authentication

This commit is contained in:
Yohan Boniface 2025-01-02 17:43:12 +01:00
parent 698c74b427
commit 460a0c9997

View file

@ -75,6 +75,8 @@ class Peer(models.Model):
**connection_params, **connection_params,
autocommit=True, autocommit=True,
) )
async def listen(self):
asyncio.create_task(self.listen_public()) asyncio.create_task(self.listen_public())
asyncio.create_task(self.listen_private()) asyncio.create_task(self.listen_private())
@ -116,6 +118,7 @@ class Peer(models.Model):
if "edit" not in permissions: if "edit" not in permissions:
return await self.disconnect() return await self.disconnect()
await self.asave() await self.asave()
await self.listen()
response = JoinResponse(uuid=str(self.uuid), peers=await self.get_peers()) response = JoinResponse(uuid=str(self.uuid), peers=await self.get_peers())
await self.send(response.model_dump_json()) await self.send(response.model_dump_json())
await self.send_peers_list() await self.send_peers_list()