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'); });