[CORE][ActivityStreamsTwo][ActivityPub] Set all routes

Allow global routes to act for every actor
Fix Favoured stream query
This commit is contained in:
2021-09-16 17:04:05 +01:00
parent 738168461c
commit d6f31d102a
17 changed files with 308 additions and 58 deletions

View File

@@ -4,7 +4,6 @@ namespace Plugin\ActivityStreamsTwo;
use App\Core\Event;
use App\Core\Modules\Plugin;
use App\Core\Router\RouteLoader;
use Exception;
use Plugin\ActivityStreamsTwo\Util\Response\ActorResponse;
use Plugin\ActivityStreamsTwo\Util\Response\NoteResponse;
@@ -41,33 +40,24 @@ class ActivityStreamsTwo extends Plugin
return Event::next;
}
switch ($route) {
case 'actor_view_id':
case 'actor_view_nickname':
$response = ActorResponse::handle($vars['gsactor']);
return Event::stop;
case 'note_view':
$response = NoteResponse::handle($vars['note']);
return Event::stop;
case 'gsactor_view_id':
case 'gsactor_view_nickname':
$response = ActorResponse::handle($vars['gsactor']);
case 'actor_favourites':
$response = LikeResponse::handle($vars['gsactor']);
return Event::stop;
case 'actor_subscriptions':
$response = FollowingResponse::handle($vars['gsactor']);
return Event::stop;
case 'actor_subscribers':
$response = FollowersResponse::handle($vars['gsactor']);
return Event::stop;
default:
return Event::next;
}
}
/**
* This code executes when GNU social creates the page routing, and we hook
* on this event to add our action handler for Embed.
*
* @param RouteLoader $r the router that was initialized.
*
* @return bool
*/
public function onAddRoute(RouteLoader $r): bool
{
/*$r->connect('note_view_as2',
'/note/{id<\d+>}',
[NoteResponse::class, 'handle'],
options: ['accept' => self::$accept_headers]
);*/
return Event::next;
}
}

View File

@@ -19,7 +19,7 @@ class GSActorToType
*/
public static function translate(GSActor $gsactor)
{
$uri = Router::url('gsactor_view_id', ['id' => $gsactor->getId()], Router::ABSOLUTE_URL);
$uri = Router::url('actor_view_id', ['id' => $gsactor->getId()], Router::ABSOLUTE_URL);
$attr = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $uri,
@@ -42,7 +42,7 @@ class GSActorToType
'summary' => $gsactor->getBio(),
//'tag' =>
'updated' => $gsactor->getModified()->format(DateTimeInterface::RFC3339),
'url' => Router::url('gsactor_view_nickname', ['nickname' => $gsactor->getNickname()], Router::ABSOLUTE_URL),
'url' => Router::url('actor_view_nickname', ['nickname' => $gsactor->getNickname()], Router::ABSOLUTE_URL),
];
return Type::create(type: 'Person', attributes: $attr);
}