From 93c7af746401c5d07ce6eb7f179118f16c8f6e63 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 11 Jun 2021 00:03:41 -0600 Subject: [PATCH] Update routes, add legacy webfinger profile redirect --- app/Http/Controllers/SiteController.php | 15 +++++++++++++++ routes/web.php | 1 + 2 files changed, 16 insertions(+) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 23b81d6a0..5b4e42abb 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -139,4 +139,19 @@ class SiteController extends Controller return redirect($url); } + + public function legacyWebfingerRedirect(Request $request, $username, $domain) + { + $un = '@'.$username.'@'.$domain; + $profile = Profile::whereUsername($un) + ->firstOrFail(); + + if($profile->domain == null) { + $url = "/$profile->username"; + } else { + $url = $request->user() ? "/i/web/profile/_/{$profile->id}" : $profile->url(); + } + + return redirect($url); + } } diff --git a/routes/web.php b/routes/web.php index 42bc0667d..4761eb86b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -492,6 +492,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('p/{username}/{id}.json', 'StatusController@showObject'); Route::get('p/{username}/{id}', 'StatusController@show'); Route::get('{username}/embed', 'ProfileController@embed'); + Route::get('@{username}@{domain}', 'SiteController@legacyWebfingerRedirect'); Route::get('@{username}', 'SiteController@legacyProfileRedirect'); Route::get('{username}', 'ProfileController@show'); });