diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index f9878281a..a9102ee9a 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -3005,51 +3005,18 @@ class ApiV1Controller extends Controller ->values() ->toArray(); } elseif ($remote && ! $local) { - 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); - } elseif ($min) { - $feed = NetworkTimelineService::getRankedMinId($min, $limit + 5); - } else { - $feed = NetworkTimelineService::get(0, $limit + 5); + Cache::remember('api:v1:timelines:network:cache_check', 10368000, function () { + if (NetworkTimelineService::count() == 0) { + NetworkTimelineService::warmCache(true, config('instance.timeline.network.cache_dropoff')); } - } else { - $feed = Status::select( - 'id', - 'uri', - 'type', - 'scope', - 'local', - 'created_at', - 'profile_id', - 'in_reply_to_id', - 'reblog_of_id' - ) - ->when($minOrMax, function ($q, $minOrMax) use ($min, $max) { - $dir = $min ? '>' : '<'; - $id = $min ?? $max; + }); - return $q->where('id', $dir, $id); - }) - ->whereNull(['in_reply_to_id', 'reblog_of_id']) - ->when($hideNsfw, function ($q, $hideNsfw) { - return $q->where('is_nsfw', false); - }) - ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) - ->whereLocal(false) - ->whereScope('public') - ->where('id', '>', $amin) - ->orderByDesc('id') - ->limit(($limit * 2)) - ->pluck('id') - ->values() - ->toArray(); + if ($max) { + $feed = NetworkTimelineService::getRankedMaxId($max, $limit + 5); + } elseif ($min) { + $feed = NetworkTimelineService::getRankedMinId($min, $limit + 5); + } else { + $feed = NetworkTimelineService::get(0, $limit + 5); } } else { if (config('instance.timeline.local.cached')) { diff --git a/app/Http/Controllers/PublicApiController.php b/app/Http/Controllers/PublicApiController.php index 932a0280c..d93a4ae44 100644 --- a/app/Http/Controllers/PublicApiController.php +++ b/app/Http/Controllers/PublicApiController.php @@ -531,103 +531,38 @@ class PublicApiController extends Controller $filtered = $user ? UserFilterService::filters($user->profile_id) : []; $hideNsfw = config('instance.hide_nsfw_on_public_feeds'); - if (config('instance.timeline.network.cached') == false) { - if ($min || $max) { - $dir = $min ? '>' : '<'; - $id = $min ?? $max; - $timeline = Status::select( - 'id', - 'uri', - 'type', - 'scope', - 'created_at', - ) - ->where('id', $dir, $id) - ->when($hideNsfw, function ($q, $hideNsfw) { - return $q->where('is_nsfw', false); - }) - ->whereNull(['in_reply_to_id', 'reblog_of_id']) - ->whereNotIn('profile_id', $filtered) - ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) - ->whereNotNull('uri') - ->whereScope('public') - ->where('id', '>', $amin) - ->orderBy('created_at', 'desc') - ->limit($limit) - ->get() - ->map(function ($s) use ($user) { - $status = StatusService::get($s->id); - $status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id); - $status['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $s->id); - $status['reblogged'] = (bool) ReblogService::get($user->profile_id, $s->id); - - return $status; - }); - $res = $timeline->toArray(); - } else { - $timeline = Status::select( - 'id', - 'uri', - 'type', - 'scope', - 'created_at', - ) - ->whereNull(['in_reply_to_id', 'reblog_of_id']) - ->whereNotIn('profile_id', $filtered) - ->when($hideNsfw, function ($q, $hideNsfw) { - return $q->where('is_nsfw', false); - }) - ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) - ->whereNotNull('uri') - ->whereScope('public') - ->where('id', '>', $amin) - ->orderBy('created_at', 'desc') - ->limit($limit) - ->get() - ->map(function ($s) use ($user) { - $status = StatusService::get($s->id); - $status['favourited'] = (bool) LikeService::liked($user->profile_id, $s->id); - $status['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $s->id); - $status['reblogged'] = (bool) ReblogService::get($user->profile_id, $s->id); - - return $status; - }); - $res = $timeline->toArray(); + Cache::remember('api:v1:timelines:network:cache_check', 10368000, function () { + if (NetworkTimelineService::count() == 0) { + NetworkTimelineService::warmCache(true, 400); } - } else { - Cache::remember('api:v1:timelines:network:cache_check', 10368000, function () { - if (NetworkTimelineService::count() == 0) { - NetworkTimelineService::warmCache(true, 400); - } - }); + }); - if ($max) { - $feed = NetworkTimelineService::getRankedMaxId($max, $limit); - } elseif ($min) { - $feed = NetworkTimelineService::getRankedMinId($min, $limit); - } else { - $feed = NetworkTimelineService::get(0, $limit); - } + if ($max) { + $feed = NetworkTimelineService::getRankedMaxId($max, $limit); + } elseif ($min) { + $feed = NetworkTimelineService::getRankedMinId($min, $limit); + } else { + $feed = NetworkTimelineService::get(0, $limit); + } - $res = collect($feed) - ->take($limit) - ->map(function ($k) use ($user) { - $status = StatusService::get($k); - if ($status && isset($status['account']) && $user) { - $status['favourited'] = (bool) LikeService::liked($user->profile_id, $k); - $status['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $k); - $status['reblogged'] = (bool) ReblogService::get($user->profile_id, $k); - $status['relationship'] = RelationshipService::get($user->profile_id, $status['account']['id']); - } + $res = collect($feed) + ->take($limit) + ->map(function ($k) use ($user) { + $status = StatusService::get($k); + if ($status && isset($status['account']) && $user) { + $status['favourited'] = (bool) LikeService::liked($user->profile_id, $k); + $status['bookmarked'] = (bool) BookmarkService::get($user->profile_id, $k); + $status['reblogged'] = (bool) ReblogService::get($user->profile_id, $k); + $status['relationship'] = RelationshipService::get($user->profile_id, $status['account']['id']); + } - return $status; - }) - ->filter(function ($s) use ($filtered) { - return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false; - }) - ->values() - ->toArray(); - } + return $status; + }) + ->filter(function ($s) use ($filtered) { + return $s && isset($s['account']) && in_array($s['account']['id'], $filtered) == false; + }) + ->values() + ->toArray(); return response()->json($res); } diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index 84b62f906..456c11795 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -698,9 +698,7 @@ class Helpers */ public static function handleStatusPostProcessing(Status $status, int $profileId, string $url): void { - if (config('instance.timeline.network.cached') && - self::isEligibleForNetwork($status) - ) { + if (self::isEligibleForNetwork($status)) { $urlDomain = parse_url($url, PHP_URL_HOST); $filteredDomains = self::getFilteredDomains(); diff --git a/config/instance.php b/config/instance.php index aa435fb9a..45cefa40d 100644 --- a/config/instance.php +++ b/config/instance.php @@ -35,7 +35,6 @@ return [ ], 'network' => [ - 'cached' => env('PF_NETWORK_TIMELINE') ? env('INSTANCE_NETWORK_TIMELINE_CACHED', true) : false, 'cache_dropoff' => env('INSTANCE_NETWORK_TIMELINE_CACHE_DROPOFF', 10000), 'max_hours_old' => env('INSTANCE_NETWORK_TIMELINE_CACHE_MAX_HOUR_INGEST', 2160), ], diff --git a/resources/views/admin/diagnostics/home.blade.php b/resources/views/admin/diagnostics/home.blade.php index 0bc6cc07a..25ebf925c 100644 --- a/resources/views/admin/diagnostics/home.blade.php +++ b/resources/views/admin/diagnostics/home.blade.php @@ -523,11 +523,6 @@ {{config_cache('instance.timeline.local.is_public') ? '✅ true' : '❌ false' }} - - INSTANCE - INSTANCE_NETWORK_TIMELINE_CACHED - {{config('instance.timeline.network.cached') }} - INSTANCE INSTANCE_NETWORK_TIMELINE_CACHE_DROPOFF