From a5e64da69bd6e57789c644fa14c0ef90ad4f5eda Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 3 May 2021 17:55:06 -0600 Subject: [PATCH 1/2] Update LikeService, fix likedBy method --- app/Services/LikeService.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Services/LikeService.php b/app/Services/LikeService.php index 8ed2bfc3a..36f31ee44 100644 --- a/app/Services/LikeService.php +++ b/app/Services/LikeService.php @@ -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, From 5d2f57598445d1d3bf128d3e8f4543661a711ce8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 3 May 2021 17:55:34 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f032f0e0..5864089c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,7 @@ - Updated StatusTransformers, add liked_by attribute. ([372bacb0](https://github.com/pixelfed/pixelfed/commit/372bacb0)) - Updated PostComponent, change like logic. ([0a35f5d6](https://github.com/pixelfed/pixelfed/commit/0a35f5d6)) - Updated Timeline component, change like logic. ([7bcbf96b](https://github.com/pixelfed/pixelfed/commit/7bcbf96b)) +- Updated LikeService, fix likedBy method. ([a5e64da6](https://github.com/pixelfed/pixelfed/commit/a5e64da6)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)