From 34203afe44480bff8f6c8eb25dd7081d7ff8d73c Mon Sep 17 00:00:00 2001 From: Petitminion Date: Wed, 4 Jun 2025 02:36:11 +0200 Subject: [PATCH] fix(backend):AttributeError: 'AnonymousUser' object has no attribute 'get_channels_groups' --- api/funkwhale_api/common/consumers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api/funkwhale_api/common/consumers.py b/api/funkwhale_api/common/consumers.py index 9db4138ff..992cbde41 100644 --- a/api/funkwhale_api/common/consumers.py +++ b/api/funkwhale_api/common/consumers.py @@ -19,6 +19,10 @@ class JsonAuthConsumer(JsonWebsocketConsumer): channels.group_add(group, self.channel_name) def disconnect(self, close_code): - groups = self.scope["user"].get_channels_groups() + self.groups + if self.scope.get("user", False) and self.scope.get("user").pk is not None: + groups = self.scope["user"].get_channels_groups() + self.groups + else: + groups = self.groups + for group in groups: channels.group_discard(group, self.channel_name)