1
0
Fork 0
forked from mirror/pixelfed

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