mirror of https://github.com/pixelfed/pixelfed.git
Update PublicApiController, add recent feed support to home timeline
This commit is contained in:
parent
f3bf2fd41e
commit
1e230e80fb
|
@ -12,6 +12,7 @@ use App\{
|
||||||
Profile,
|
Profile,
|
||||||
StatusHashtag,
|
StatusHashtag,
|
||||||
Status,
|
Status,
|
||||||
|
StatusView,
|
||||||
UserFilter
|
UserFilter
|
||||||
};
|
};
|
||||||
use Auth,Cache;
|
use Auth,Cache;
|
||||||
|
@ -376,9 +377,13 @@ class PublicApiController extends Controller
|
||||||
'page' => 'nullable|integer|max:40',
|
'page' => 'nullable|integer|max:40',
|
||||||
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
'min_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
||||||
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
'max_id' => 'nullable|integer|min:0|max:' . PHP_INT_MAX,
|
||||||
'limit' => 'nullable|integer|max:40'
|
'limit' => 'nullable|integer|max:40',
|
||||||
|
'recent_feed' => 'nullable',
|
||||||
|
'recent_min' => 'nullable|integer'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$recentFeed = $request->input('recent_feed') == 'true';
|
||||||
|
$recentFeedMin = $request->input('recent_min');
|
||||||
$page = $request->input('page');
|
$page = $request->input('page');
|
||||||
$min = $request->input('min_id');
|
$min = $request->input('min_id');
|
||||||
$max = $request->input('max_id');
|
$max = $request->input('max_id');
|
||||||
|
@ -393,29 +398,21 @@ class PublicApiController extends Controller
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Use redis for timelines
|
$pid = Auth::user()->profile_id;
|
||||||
// $timeline = Timeline::build()->local();
|
|
||||||
$pid = Auth::user()->profile->id;
|
|
||||||
|
|
||||||
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) {
|
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function() use($pid) {
|
||||||
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
||||||
return $following->push($pid)->toArray();
|
return $following->push($pid)->toArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
// $private = Cache::remember('profiles:private', now()->addMinutes(1440), function() {
|
if($recentFeed == true) {
|
||||||
// return Profile::whereIsPrivate(true)
|
$key = 'profile:home-timeline-cursor:'.$user->id;
|
||||||
// ->orWhere('unlisted', true)
|
$ttl = now()->addMinutes(30);
|
||||||
// ->orWhere('status', '!=', null)
|
$min = Cache::remember($key, $ttl, function() use($pid) {
|
||||||
// ->pluck('id');
|
$res = StatusView::whereProfileId($pid)->orderByDesc('status_id')->first();
|
||||||
// });
|
return $res ? $res->status_id : null;
|
||||||
|
});
|
||||||
// $private = $private->diff($following)->flatten();
|
}
|
||||||
|
|
||||||
// $filters = UserFilter::whereUserId($pid)
|
|
||||||
// ->whereFilterableType('App\Profile')
|
|
||||||
// ->whereIn('filter_type', ['mute', 'block'])
|
|
||||||
// ->pluck('filterable_id')->toArray();
|
|
||||||
// $filtered = array_merge($private->toArray(), $filters);
|
|
||||||
|
|
||||||
$filtered = Auth::check() ? UserFilterService::filters(Auth::user()->profile_id) : [];
|
$filtered = Auth::check() ? UserFilterService::filters(Auth::user()->profile_id) : [];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue