mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 01:59:19 +02:00
Resolve "Per-user libraries" (use !368 instead)
This commit is contained in:
parent
b0ca181016
commit
2ea21994ee
144 changed files with 6749 additions and 5347 deletions
|
@ -1,6 +1,25 @@
|
|||
import json
|
||||
import logging
|
||||
|
||||
from asgiref.sync import async_to_sync
|
||||
from channels.layers import get_channel_layer
|
||||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
|
||||
logger = logging.getLogger(__file__)
|
||||
channel_layer = get_channel_layer()
|
||||
group_send = async_to_sync(channel_layer.group_send)
|
||||
group_add = async_to_sync(channel_layer.group_add)
|
||||
|
||||
|
||||
def group_send(group, event):
|
||||
# we serialize the payload ourselves and deserialize it to ensure it
|
||||
# works with msgpack. This is dirty, but we'll find a better solution
|
||||
# later
|
||||
s = json.dumps(event, cls=DjangoJSONEncoder)
|
||||
event = json.loads(s)
|
||||
logger.debug(
|
||||
"[channels] Dispatching %s to group %s: %s",
|
||||
event["type"],
|
||||
group,
|
||||
{"type": event["data"]["type"]},
|
||||
)
|
||||
async_to_sync(channel_layer.group_send)(group, event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue