[CORE][Actor] Fix generic profile route

This commit is contained in:
Diogo Peralta Cordeiro 2022-02-16 18:45:30 +00:00
parent cee2d143c9
commit b6ed0b4c6c
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 8 additions and 7 deletions

View File

@ -188,6 +188,7 @@ class ActivityPub extends Plugin
return Event::next;
}
switch ($route) {
case 'actor_view_id':
case 'person_actor_view_id':
case 'person_actor_view_nickname':
case 'group_actor_view_id':

View File

@ -23,23 +23,23 @@ declare(strict_types = 1);
namespace App\Controller;
use App\Core\Controller;
use App\Core\Router\Router;
use App\Entity\Actor;
use Component\Collection\Util\Controller\FeedController;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
class ActorFeed extends FeedController
class ActorProfile extends Controller
{
public function actorViewId(Request $request, int $id): RedirectResponse
public function actorViewId(Request $request, int $id): array
{
$route_id = match (Actor::getById($id)->getType()) {
$actor = Actor::getById($id);
$route_id = match ($actor->getType()) {
Actor::PERSON => 'person_actor_view_id',
Actor::GROUP => 'group_actor_view_id',
Actor::BOT => 'bot_actor_view_id',
default => throw new InvalidArgumentException(),
};
return new RedirectResponse(Router::url($route_id, ['id' => $id]), status: 302);
return ['_redirect' => Router::url($route_id, ['id' => $id]), 'actor' => $actor];
}
}

View File

@ -44,6 +44,6 @@ abstract class Actor
public static function load(RouteLoader $r): void
{
$r->connect(id: 'actor_view_id', uri_path: '/actor/{id<\d+>}', target: [C\ActorFeed::class, 'actorViewId']);
$r->connect(id: 'actor_view_id', uri_path: '/actor/{id<\d+>}', target: [C\ActorProfile::class, 'actorViewId']);
}
}