Update routes, add legacy webfinger profile redirect

This commit is contained in:
Daniel Supernault 2021-06-11 00:03:41 -06:00
parent 07321b021c
commit 93c7af7464
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
2 changed files with 16 additions and 0 deletions

View File

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

View File

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