123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App\Http\Controllers;
- use Auth;
- use App\Follower;
- use App\Profile;
- use App\Status;
- use App\User;
- use App\UserFilter;
- use Illuminate\Http\Request;
- class TimelineController extends Controller
- {
- public function __construct()
- {
- $this->middleware('auth');
- $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)
- {
- $this->validate($request,[
- 'page' => 'nullable|integer|max:20'
- ]);
- // TODO: Use redis for timelines
- // $timeline = Timeline::build()->local();
- $pid = Auth::user()->profile->id;
- $filtered = UserFilter::whereUserId($pid)
- ->whereFilterableType('App\Profile')
- ->whereIn('filter_type', ['mute', 'block'])
- ->pluck('filterable_id');
- $private = Profile::whereIsPrivate(true)->pluck('id');
- $filtered = $filtered->merge($private);
- $timeline = Status::whereHas('media')
- ->whereNotIn('profile_id', $filtered)
- ->whereNull('in_reply_to_id')
- ->whereNull('reblog_of_id')
- ->whereVisibility('public')
- ->withCount(['comments', 'likes'])
- ->orderBy('created_at', 'desc')
- ->simplePaginate(10);
- $type = 'local';
- return view('timeline.template', compact('timeline', 'type'));
- }
- }
|