mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-24 14:03:16 +00:00
Update TimelineController
This commit is contained in:
parent
8fecceed51
commit
53e8da4837
1 changed files with 8 additions and 30 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
use Auth, Cache;
|
||||||
use App\Follower;
|
use App\Follower;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Status;
|
use App\Status;
|
||||||
|
@ -18,30 +18,6 @@ class TimelineController extends Controller
|
||||||
$this->middleware('twofactor');
|
$this->middleware('twofactor');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function personal(Request $request)
|
|
||||||
{
|
|
||||||
$this->validate($request,[
|
|
||||||
'page' => 'nullable|integer|max:20'
|
|
||||||
]);
|
|
||||||
$pid = Auth::user()->profile->id;
|
|
||||||
// TODO: Use redis for timelines
|
|
||||||
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
|
||||||
$following->push($pid);
|
|
||||||
$filtered = UserFilter::whereUserId($pid)
|
|
||||||
->whereFilterableType('App\Profile')
|
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
|
||||||
->pluck('filterable_id');
|
|
||||||
$timeline = Status::whereIn('profile_id', $following)
|
|
||||||
->whereNotIn('profile_id', $filtered)
|
|
||||||
->whereVisibility('public')
|
|
||||||
->orderBy('created_at', 'desc')
|
|
||||||
->withCount(['comments', 'likes'])
|
|
||||||
->simplePaginate(10);
|
|
||||||
$type = 'personal';
|
|
||||||
|
|
||||||
return view('timeline.template', compact('timeline', 'type'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function local(Request $request)
|
public function local(Request $request)
|
||||||
{
|
{
|
||||||
$this->validate($request,[
|
$this->validate($request,[
|
||||||
|
@ -51,12 +27,14 @@ class TimelineController extends Controller
|
||||||
// $timeline = Timeline::build()->local();
|
// $timeline = Timeline::build()->local();
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
|
|
||||||
$filtered = UserFilter::whereUserId($pid)
|
$filtered = Cache::rememberForever("user:filter:list:$pid", function() use($pid) {
|
||||||
->whereFilterableType('App\Profile')
|
return UserFilter::whereUserId($pid)
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
->whereFilterableType('App\Profile')
|
||||||
->pluck('filterable_id');
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
|
->pluck('filterable_id')->toArray();
|
||||||
|
});
|
||||||
$private = Profile::whereIsPrivate(true)->pluck('id');
|
$private = Profile::whereIsPrivate(true)->pluck('id');
|
||||||
$filtered = $filtered->merge($private);
|
$filtered = array_merge($private->toArray(), $filtered);
|
||||||
$timeline = Status::whereHas('media')
|
$timeline = Status::whereHas('media')
|
||||||
->whereNotIn('profile_id', $filtered)
|
->whereNotIn('profile_id', $filtered)
|
||||||
->whereNull('in_reply_to_id')
|
->whereNull('in_reply_to_id')
|
||||||
|
|
Loading…
Reference in a new issue