[COMPONENT][Posting] Fix request handling issues that resulted from splitting creation and controller

This commit is contained in:
2022-03-11 03:14:47 +00:00
parent cf05d3dbb0
commit d8108dbc32
4 changed files with 65 additions and 40 deletions

View File

@@ -85,13 +85,21 @@ class Group extends Component
*/
private function getGroupFromContext(Request $request): ?Actor
{
if (str_starts_with($request->get('_route'), 'group_actor_view_')) {
if (!\is_null($id = $request->get('id'))) {
return Actor::getById((int) $id);
}
if (!\is_null($nickname = $request->get('nickname'))) {
return LocalGroup::getActorByNickname($nickname);
if (\is_array($request->get('post_note')) && \array_key_exists('_next', $request->get('post_note'))) {
$next = parse_url($request->get('post_note')['_next']);
$match = Router::match($next['path']);
$route = $match['_route'];
$identifier = $match['id'] ?? $match['nickname'] ?? null;
} else {
$route = $request->get('_route');
$identifier = $request->get('id') ?? $request->get('nickname');
}
if (str_starts_with($route, 'group_actor_view_')) {
switch ($route) {
case 'group_actor_view_nickname':
return LocalGroup::getActorByNickname($identifier);
case 'group_actor_view_id':
return Actor::getById($identifier);
}
}
return null;