wip(sync): only save Peer after authentication

This commit is contained in:
Yohan Boniface 2025-01-02 17:40:17 +01:00
parent a29eae138e
commit 698c74b427
2 changed files with 2 additions and 2 deletions

View file

@ -17,7 +17,7 @@ async def application(scope, receive, send):
map_id = kwargs["map_id"]
room_id = f"room{map_id}"
peer = await Peer.objects.acreate(uuid=uuid.uuid4(), name="FooBar", room_id=room_id)
peer = Peer(uuid=uuid.uuid4(), name="FooBar", room_id=room_id)
print(peer)
peer._send = send
while True:

View file

@ -115,7 +115,7 @@ class Peer(models.Model):
user, map_id, permissions = signed.values()
if "edit" not in permissions:
return await self.disconnect()
await Peer.asave()
await self.asave()
response = JoinResponse(uuid=str(self.uuid), peers=await self.get_peers())
await self.send(response.model_dump_json())
await self.send_peers_list()