diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index f56d65880..dbe31588a 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -48,6 +48,23 @@ class ProfileController extends Controller return view('profile.show', compact('user', 'settings', 'owner', 'is_following', 'is_admin', 'timeline')); } + public function permalinkRedirect(Request $request, $username) + { + $user = Profile::whereUsername($username)->firstOrFail(); + $settings = User::whereUsername($username)->firstOrFail()->settings; + + $mimes = [ + 'application/activity+json', + 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' + ]; + + if(in_array($request->header('accept'), $mimes) && config('pixelfed.activitypub_enabled')) { + return $this->showActivityPub($request, $user); + } + + return redirect($user->url()); + } + protected function privateProfileCheck(Profile $profile) { if(Auth::check() === false) { diff --git a/routes/web.php b/routes/web.php index 53f34cc70..41625e378 100644 --- a/routes/web.php +++ b/routes/web.php @@ -123,9 +123,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware('validemail')->group(fu Route::redirect('/', '/'); Route::get('{user}.atom', 'ProfileController@showAtomFeed'); Route::get('{username}/outbox', 'FederationController@userOutbox'); - Route::get('{user}', function($user) { - return redirect('/'.$user); - }); + Route::get('{username}', 'ProfileController@permalinkRedirect'); }); Route::get('p/{username}/{id}/c/{cid}', 'CommentController@show');