fix(profiles): online null when not authenticated

This commit is contained in:
AdrienLSH 2024-04-28 09:50:38 +02:00
parent 9fea10fc91
commit 4351c335cb
3 changed files with 8 additions and 2 deletions

View File

@ -30,6 +30,11 @@ export class Profile extends AExchangeable
*/ */
this.avatar = avatar; this.avatar = avatar;
/**
* @type {Boolean}
**/
this.online = null;
/** /**
* @type {Boolean} * @type {Boolean}
*/ */
@ -58,6 +63,7 @@ export class Profile extends AExchangeable
this.id = response_data.id; this.id = response_data.id;
this.username = response_data.username; this.username = response_data.username;
this.avatar = response_data.avatar; this.avatar = response_data.avatar;
this.online = response_data.online
if (!this.client.me || this.client.me.id === this.id) if (!this.client.me || this.client.me.id === this.id)
return; return;

View File

@ -25,7 +25,7 @@ class ProfileSerializer(serializers.ModelSerializer):
user = request.user user = request.user
if user is None: if user is None:
return False return None
if user.pk == obj.pk: if user.pk == obj.pk:
return True return True

View File

@ -35,4 +35,4 @@ class MyProfileViewSet(viewsets.ModelViewSet):
return Response(ProfileSerializer(profile).data) return Response(ProfileSerializer(profile).data)
def retrieve(self, pk=None): def retrieve(self, pk=None):
return Response(self.serializer_class(self.get_object()).data) return Response(self.serializer_class(self.get_object(), context={'request': self.request}).data)