音楽で楽しみましょう!-Let's have fun with music!-
Signed-off-by: Shin'ya Minazuki <shinyoukai@laidback.moe>
This commit is contained in:
parent
7c3206bf83
commit
54c6d22102
517 changed files with 637 additions and 639 deletions
24
api/funquail_api/common/consumers.py
Normal file
24
api/funquail_api/common/consumers.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from channels.generic.websocket import JsonWebsocketConsumer
|
||||
|
||||
from funkwhale_api.common import channels
|
||||
|
||||
|
||||
class JsonAuthConsumer(JsonWebsocketConsumer):
|
||||
def connect(self):
|
||||
try:
|
||||
assert self.scope["user"].pk is not None
|
||||
except (AssertionError, AttributeError, KeyError):
|
||||
return self.close()
|
||||
|
||||
return self.accept()
|
||||
|
||||
def accept(self):
|
||||
super().accept()
|
||||
groups = self.scope["user"].get_channels_groups() + self.groups
|
||||
for group in groups:
|
||||
channels.group_add(group, self.channel_name)
|
||||
|
||||
def disconnect(self, close_code):
|
||||
groups = self.scope["user"].get_channels_groups() + self.groups
|
||||
for group in groups:
|
||||
channels.group_discard(group, self.channel_name)
|
||||
Loading…
Add table
Add a link
Reference in a new issue