1
0
Fork 0
forked from mirror/pixelfed

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'); $max = $request->input('max_id');
$limit = $request->input('limit') ?? 20; $limit = $request->input('limit') ?? 20;
$pid = $request->user()->profile_id; $pid = $request->user()->profile_id;
$includeReblogs = $request->filled('include_reblogs'); $includeReblogs = $request->filled('include_reblogs') ? $request->boolean('include_reblogs') : false;
$nullFields = $includeReblogs ? $nullFields = $includeReblogs ?
['in_reply_to_id'] : ['in_reply_to_id'] :
['in_reply_to_id', 'reblog_of_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']; ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'];
if(config('exp.cached_home_timeline')) { if(config('exp.cached_home_timeline')) {
$paddedLimit = $includeReblogs ? $limit + 10 : $limit + 50;
if($min || $max) { if($min || $max) {
if($request->has('min_id')) { if($request->has('min_id')) {
$res = HomeTimelineService::getRankedMinId($pid, $min ?? 0, $limit + 10); $res = HomeTimelineService::getRankedMinId($pid, $min ?? 0, $paddedLimit);
} else { } else {
$res = HomeTimelineService::getRankedMaxId($pid, $max ?? 0, $limit + 10); $res = HomeTimelineService::getRankedMaxId($pid, $max ?? 0, $paddedLimit);
} }
} else { } else {
$res = HomeTimelineService::get($pid, 0, $limit + 10); $res = HomeTimelineService::get($pid, 0, $paddedLimit);
} }
if(!$res) { if(!$res) {