forked from mirror/pixelfed
Update SiteController, add legacy profile/webfinger redirect
This commit is contained in:
parent
287aef284b
commit
cfaa248c72
2 changed files with 25 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use App, Auth, Cache, View;
|
||||
use App\Util\Lexer\PrettyNumber;
|
||||
use App\{Follower, Page, Profile, Status, User, UserFilter};
|
||||
|
@ -129,4 +130,27 @@ class SiteController extends Controller
|
|||
$following = $user != null ? FollowerService::follows($user->profile_id, $profile->id) : false;
|
||||
return view('site.intents.follow', compact('profile', 'user', 'following'));
|
||||
}
|
||||
|
||||
public function legacyProfileRedirect(Request $request, $username)
|
||||
{
|
||||
$username = Str::contains($username, '@') ? '@' . $username : $username;
|
||||
if(str_contains($username, '@')) {
|
||||
$profile = Profile::whereUsername($username)
|
||||
->firstOrFail();
|
||||
|
||||
if($profile->domain == null) {
|
||||
$url = "/$profile->username";
|
||||
} else {
|
||||
$url = "/i/web/profile/_/{$profile->id}";
|
||||
}
|
||||
|
||||
} else {
|
||||
$profile = Profile::whereUsername($username)
|
||||
->whereNull('domain')
|
||||
->firstOrFail();
|
||||
$url = "/$profile->username";
|
||||
}
|
||||
|
||||
return redirect($url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -428,5 +428,6 @@ 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}', 'SiteController@legacyProfileRedirect');
|
||||
Route::get('{username}', 'ProfileController@show');
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue