fix(kfet/open): Wrap sync function for async use

This commit is contained in:
Tom Hubrecht 2025-01-16 18:47:11 +01:00
parent 9ec07f426c
commit e4e6dfe7c6
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc

View file

@ -1,3 +1,5 @@
from asgiref.sync import sync_to_async
from ..decorators import kfet_is_team from ..decorators import kfet_is_team
from ..utils import DjangoJsonWebsocketConsumer, PermConsumerMixin from ..utils import DjangoJsonWebsocketConsumer, PermConsumerMixin
from .open import kfet_open from .open import kfet_open
@ -19,7 +21,7 @@ class OpenKfetConsumer(PermConsumerMixin, DjangoJsonWebsocketConsumer):
"""Send current status on connect.""" """Send current status on connect."""
await super().connect() await super().connect()
group = "team" if kfet_is_team(self.user) else "base" group = "team" if await sync_to_async(kfet_is_team)(self.user) else "base"
await self.channel_layer.group_add(f"kfet.open.{group}", self.channel_name) await self.channel_layer.group_add(f"kfet.open.{group}", self.channel_name)