Sfoglia il codice sorgente

Add local timeline to TimelineController

Daniel Supernault 7 anni fa
parent
commit
a7b186d7fb
1 ha cambiato i file con 13 aggiunte e 2 eliminazioni
  1. 13 2
      app/Http/Controllers/TimelineController.php

+ 13 - 2
app/Http/Controllers/TimelineController.php

@@ -3,7 +3,8 @@
 namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
-use App\{Status, User};
+use Auth;
+use App\{Follower, Status, User};
 
 class TimelineController extends Controller
 {
@@ -14,7 +15,17 @@ class TimelineController extends Controller
 
     public function personal()
     {
-      $timeline = Status::orderBy('id','desc')->paginate(10);
+      // TODO: Use redis for timelines
+      $following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
+      $timeline = Status::whereHas('media')->whereNull('in_reply_to_id')->whereIn('profile_id', $following)->orderBy('id','desc')->simplePaginate(10);
       return view('timeline.personal', compact('timeline'));
     }
+
+    public function local()
+    {
+      // TODO: Use redis for timelines
+      $timeline = Status::whereHas('media')->whereNull('in_reply_to_id')->orderBy('id','desc')->simplePaginate(10);
+      return view('timeline.public', compact('timeline'));
+    }
+
 }