Update ApiV1Controller, fix include_reblogs param on timelines/home endpoint, and improve limit pagination logic

This commit is contained in:
Daniel Supernault 2023-11-17 20:50:07 -07:00
parent 175203089b
commit 287f903bf3
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -2146,7 +2146,7 @@ class ApiV1Controller extends Controller
$max = $request->input('max_id');
$limit = $request->input('limit') ?? 20;
$pid = $request->user()->profile_id;
$includeReblogs = $request->filled('include_reblogs');
$includeReblogs = $request->filled('include_reblogs') ? $request->boolean('include_reblogs') : false;
$nullFields = $includeReblogs ?
['in_reply_to_id'] :
['in_reply_to_id', 'reblog_of_id'];
@ -2155,14 +2155,15 @@ class ApiV1Controller extends Controller
['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'];
if(config('exp.cached_home_timeline')) {
$paddedLimit = $includeReblogs ? $limit + 10 : $limit + 50;
if($min || $max) {
if($request->has('min_id')) {
$res = HomeTimelineService::getRankedMinId($pid, $min ?? 0, $limit + 10);
$res = HomeTimelineService::getRankedMinId($pid, $min ?? 0, $paddedLimit);
} else {
$res = HomeTimelineService::getRankedMaxId($pid, $max ?? 0, $limit + 10);
$res = HomeTimelineService::getRankedMaxId($pid, $max ?? 0, $paddedLimit);
}
} else {
$res = HomeTimelineService::get($pid, 0, $limit + 10);
$res = HomeTimelineService::get($pid, 0, $paddedLimit);
}
if(!$res) {