1
0
Fork 0
forked from mirror/pixelfed

Update LikeService, fix likedBy method

This commit is contained in:
Daniel Supernault 2021-05-03 17:55:06 -06:00
parent c10a94649c
commit a5e64da69b
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -50,13 +50,27 @@ class LikeService {
public static function likedBy($status)
{
if(!$status->likes_count) {
return [
'username' => null,
'others' => false
];
$empty = [
'username' => null,
'others' => false
];
if(!$status) {
return $empty;
}
$id = Like::whereStatusId($status->id)->first()->profile_id;
if(!$status->likes_count) {
return $empty;
}
$like = Like::whereStatusId($status->id)->first();
if(!$like) {
return $empty;
}
$id = $like->profile_id;
return [
'username' => ProfileService::get($id)['username'],
'others' => $status->likes_count >= 5,