From 0faf59e3b7ed2f9162e7b093867c88ee34eb1dbe Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 11 Feb 2024 14:26:45 -0700 Subject: [PATCH 1/2] Update ApiV1Controller, fix network timeline --- app/Http/Controllers/Api/ApiV1Controller.php | 40 ++++++++++++++------ config/instance.php | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index d1bd9cac2..fed120b40 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -2536,20 +2536,38 @@ class ApiV1Controller extends Controller AccountService::setLastActive($user->id); $domainBlocks = UserFilterService::domainBlocks($user->profile_id); - if($remote && config('instance.timeline.network.cached')) { - Cache::remember('api:v1:timelines:network:cache_check', 10368000, function() { - if(NetworkTimelineService::count() == 0) { - NetworkTimelineService::warmCache(true, config('instance.timeline.network.cache_dropoff')); - } - }); + if($remote) { + if(config('instance.timeline.network.cached')) { + Cache::remember('api:v1:timelines:network:cache_check', 10368000, function() { + if(NetworkTimelineService::count() == 0) { + NetworkTimelineService::warmCache(true, config('instance.timeline.network.cache_dropoff')); + } + }); - if ($max) { - $feed = NetworkTimelineService::getRankedMaxId($max, $limit + 5); - } else if ($min) { - $feed = NetworkTimelineService::getRankedMinId($min, $limit + 5); + if ($max) { + $feed = NetworkTimelineService::getRankedMaxId($max, $limit + 5); + } else if ($min) { + $feed = NetworkTimelineService::getRankedMinId($min, $limit + 5); + } else { + $feed = NetworkTimelineService::get(0, $limit + 5); + } } else { - $feed = NetworkTimelineService::get(0, $limit + 5); + $feed = Status::select( + 'id', + 'profile_id', + 'type', + 'visibility', + 'in_reply_to_id', + 'reblog_of_id' + ) + ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) + ->where('visibility', 'public') + ->whereLocal(false) + ->orderByDesc('id') + ->take(($limit * 2)) + ->pluck('id'); } + } if($local || !$remote && !$local) { diff --git a/config/instance.php b/config/instance.php index 03f666a79..dd645d931 100644 --- a/config/instance.php +++ b/config/instance.php @@ -33,7 +33,7 @@ return [ ], 'network' => [ - 'cached' => env('PF_NETWORK_TIMELINE') ? env('INSTANCE_NETWORK_TIMELINE_CACHED', true) : false, + 'cached' => env('PF_NETWORK_TIMELINE') ? env('INSTANCE_NETWORK_TIMELINE_CACHED', false) : false, 'cache_dropoff' => env('INSTANCE_NETWORK_TIMELINE_CACHE_DROPOFF', 100), 'max_hours_old' => env('INSTANCE_NETWORK_TIMELINE_CACHE_MAX_HOUR_INGEST', 6) ] From 7b8977e9cc816f569fa345fccea4b89dfe95dad9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 11 Feb 2024 14:27:38 -0700 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de5f73b61..be720cae2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.11...dev) +### Updated + +- Update ApiV1Controller, fix network timeline ([0faf59e3](https://github.com/pixelfed/pixelfed/commit/0faf59e3)) +- ([](https://github.com/pixelfed/pixelfed/commit/)) + ## [v0.11.11 (2024-02-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.10...v0.11.11) ### Fixes @@ -27,7 +32,6 @@ ### Federation - Update Privacy Settings, add support for Mastodon `indexable` search flag ([fc24630e](https://github.com/pixelfed/pixelfed/commit/fc24630e)) - Update AP Helpers, consume actor `indexable` attribute ([fbdcdd9d](https://github.com/pixelfed/pixelfed/commit/fbdcdd9d)) -- ([](https://github.com/pixelfed/pixelfed/commit/)) ### Updates - Update FollowerService, add forget method to RelationshipService call to reduce load when mass purging ([347e4f59](https://github.com/pixelfed/pixelfed/commit/347e4f59)) @@ -112,7 +116,6 @@ - Update PublicApiController, consume InstanceService blocked domains for account and statuses endpoints ([01b33fb3](https://github.com/pixelfed/pixelfed/commit/01b33fb3)) - Update ApiV1Controller, enforce blocked instance domain logic ([5b284cac](https://github.com/pixelfed/pixelfed/commit/5b284cac)) - Update ApiV2Controller, add vapid key to instance object. Thanks thisismissem! ([4d02d6f1](https://github.com/pixelfed/pixelfed/commit/4d02d6f1)) -- ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.9 (2023-08-21)](https://github.com/pixelfed/pixelfed/compare/v0.11.8...v0.11.9)