From 582c4913d511c7996959f7def086af3294d0c55d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 10 Dec 2018 20:41:41 -0700 Subject: [PATCH] Update timeline controllers and routes --- app/Http/Controllers/SiteController.php | 23 +----------------- app/Http/Controllers/TimelineController.php | 26 +-------------------- routes/web.php | 15 ++++++------ 3 files changed, 10 insertions(+), 54 deletions(-) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index d7ab96480..fa12c9392 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -31,28 +31,7 @@ class SiteController extends Controller public function homeTimeline() { - $pid = Auth::user()->profile->id; - // TODO: Use redis for timelines - - $following = Follower::whereProfileId($pid)->pluck('following_id'); - $following->push($pid)->toArray(); - - $filtered = UserFilter::whereUserId($pid) - ->whereFilterableType('App\Profile') - ->whereIn('filter_type', ['mute', 'block']) - ->pluck('filterable_id')->toArray(); - - $timeline = Status::whereIn('profile_id', $following) - ->whereNotIn('profile_id', $filtered) - ->whereHas('media') - ->whereVisibility('public') - ->orderBy('created_at', 'desc') - ->withCount(['comments', 'likes', 'shares']) - ->simplePaginate(20); - - $type = 'personal'; - - return view('timeline.template', compact('timeline', 'type')); + return view('timeline.home'); } public function changeLocale(Request $request, $locale) diff --git a/app/Http/Controllers/TimelineController.php b/app/Http/Controllers/TimelineController.php index 5ce51eb89..417692855 100644 --- a/app/Http/Controllers/TimelineController.php +++ b/app/Http/Controllers/TimelineController.php @@ -20,30 +20,6 @@ class TimelineController extends Controller 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; - - $private = Profile::whereIsPrivate(true)->where('id', '!=', $pid)->pluck('id'); - $filters = UserFilter::whereUserId($pid) - ->whereFilterableType('App\Profile') - ->whereIn('filter_type', ['mute', 'block']) - ->pluck('filterable_id')->toArray(); - $filtered = array_merge($private->toArray(), $filters); - - $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')); + return view('timeline.local'); } } diff --git a/routes/web.php b/routes/web.php index 9e2b5a0c8..35fc89972 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,15 +38,16 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('nodeinfo/2.0.json', 'FederationController@nodeinfo'); Route::group(['prefix' => 'v1'], function () { + Route::get('accounts/verify_credentials', 'ApiController@verifyCredentials'); Route::post('avatar/update', 'ApiController@avatarUpdate'); Route::get('likes', 'ApiController@hydrateLikes'); - Route::post('media', 'ApiController@uploadMedia')->middleware('throttle:250,1440'); + Route::post('media', 'ApiController@uploadMedia')->middleware('throttle:500,1440'); + Route::get('notifications', 'ApiController@notifications'); + Route::get('timelines/public', 'PublicApiController@publicTimelineApi'); + Route::get('timelines/home', 'PublicApiController@homeTimelineApi'); }); Route::group(['prefix' => 'v2'], function() { - Route::get('notifications', 'InternalApiController@notifications'); - Route::post('notifications', 'InternalApiController@notificationMarkAllRead'); Route::get('discover', 'InternalApiController@discover'); - // Route::get('discover/people', 'InternalApiController@discoverPeople'); Route::get('discover/posts', 'InternalApiController@discoverPosts'); Route::get('profile/{username}/status/{postid}', 'PublicApiController@status'); Route::get('comments/{username}/status/{postId}', 'PublicApiController@statusComments'); @@ -56,7 +57,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::group(['prefix' => 'local'], function () { Route::get('i/follow-suggestions', 'ApiController@followSuggestions'); Route::post('i/more-comments', 'ApiController@loadMoreComments'); - Route::post('status/compose', 'InternalApiController@compose')->middleware('throttle:250,1440'); + Route::post('status/compose', 'InternalApiController@compose')->middleware('throttle:500,1440'); }); }); @@ -67,8 +68,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('compose', 'StatusController@compose')->name('compose'); Route::post('comment', 'CommentController@store')->middleware('throttle:1000,1440'); Route::post('delete', 'StatusController@delete')->middleware('throttle:1000,1440'); - Route::post('mute', 'AccountController@mute')->middleware('throttle:100,1440'); - Route::post('block', 'AccountController@block')->middleware('throttle:100,1440'); + Route::post('mute', 'AccountController@mute'); + Route::post('block', 'AccountController@block'); Route::post('like', 'LikeController@store')->middleware('throttle:1000,1440'); Route::post('share', 'StatusController@storeShare')->middleware('throttle:1000,1440'); Route::post('follow', 'FollowerController@store')->middleware('throttle:250,1440');