From d8ff40ebf91c47e2ae694b56ae31fad25c04006f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 31 Mar 2022 01:31:03 -0600 Subject: [PATCH 1/2] Update DiscoverController, improve tag feed perf --- app/Http/Controllers/DiscoverController.php | 6 +++++- app/Services/StatusHashtagService.php | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/DiscoverController.php b/app/Http/Controllers/DiscoverController.php index 60fa266ac..2277e8ee9 100644 --- a/app/Http/Controllers/DiscoverController.php +++ b/app/Http/Controllers/DiscoverController.php @@ -96,8 +96,12 @@ class DiscoverController extends Controller }) ->values(); } else { + if($page != 1) { + $res['tags'] = []; + return $res; + } $key = 'discover:tags:public_feed:' . $hashtag->id . ':page:' . $page; - $tags = Cache::remember($key, 900, function() use($hashtag, $page, $end) { + $tags = Cache::remember($key, 43200, function() use($hashtag, $page, $end) { return collect(StatusHashtagService::get($hashtag->id, $page, $end)) ->filter(function($tag) { if(!$tag['status']['local']) { diff --git a/app/Services/StatusHashtagService.php b/app/Services/StatusHashtagService.php index d0d8b2550..ececca633 100644 --- a/app/Services/StatusHashtagService.php +++ b/app/Services/StatusHashtagService.php @@ -26,7 +26,6 @@ class StatusHashtagService { return StatusHashtag::whereHashtagId($id) ->whereStatusVisibility('public') - ->whereHas('media') ->skip($stop) ->latest() ->take(9) @@ -35,7 +34,10 @@ class StatusHashtagService { return self::getStatus($i, $id); }) ->filter(function ($i) use($filtered) { - return isset($i['status']) && !empty($i['status']) && !in_array($i['status']['account']['id'], $filtered); + return isset($i['status']) && + !empty($i['status']) && !in_array($i['status']['account']['id'], $filtered) && + isset($i['status']['media_attachments']) && + !empty($i['status']['media_attachments']); }) ->values(); } From 0a7f8fd142ef22558ea3df1796378c3a06e5ffca Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 1 Apr 2022 18:40:13 -0400 Subject: [PATCH 2/2] Change static_path on custom emojis to static_url --- app/Models/CustomEmoji.php | 4 ++-- app/Services/CustomEmojiService.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Models/CustomEmoji.php b/app/Models/CustomEmoji.php index 720ea136b..45e26121d 100644 --- a/app/Models/CustomEmoji.php +++ b/app/Models/CustomEmoji.php @@ -47,7 +47,7 @@ class CustomEmoji extends Model return [ 'shortcode' => $match, 'url' => $url, - 'static_path' => $url, + 'static_url' => $url, 'visible_in_picker' => $tag->disabled == false ]; } @@ -57,7 +57,7 @@ class CustomEmoji extends Model if($activitypub == true) { return $tag && isset($tag['icon']); } else { - return $tag && isset($tag['static_path']); + return $tag && isset($tag['static_url']); } }) ->values() diff --git a/app/Services/CustomEmojiService.php b/app/Services/CustomEmojiService.php index 72615884b..74957e28e 100644 --- a/app/Services/CustomEmojiService.php +++ b/app/Services/CustomEmojiService.php @@ -118,7 +118,7 @@ class CustomEmojiService return [ 'shortcode' => str_replace(':', '', $emojo->shortcode), 'url' => $url, - 'static_path' => $url, + 'static_url' => $url, 'visible_in_picker' => $emojo->disabled == false ]; })