2021-04-02 17:20:02 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-08-27 13:26:06 +00:00
|
|
|
use CodeIgniter\Router\RouteCollection;
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2021 Ad Aures
|
2021-04-02 17:20:02 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2023-08-27 13:26:06 +00:00
|
|
|
/** @var RouteCollection $routes */
|
2021-08-23 11:05:16 +00:00
|
|
|
|
2022-11-24 15:20:43 +00:00
|
|
|
$routes->addPlaceholder('actorUsername', '[a-zA-Z0-9\_]{1,32}');
|
2021-04-02 17:20:02 +00:00
|
|
|
$routes->addPlaceholder(
|
|
|
|
'uuid',
|
|
|
|
'[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}',
|
|
|
|
);
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->addPlaceholder('postAction', '\bfavourite|\breblog|\breply');
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
/**
|
2021-08-27 10:58:22 +00:00
|
|
|
* Fediverse routes file
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
|
|
|
|
2021-05-19 16:35:13 +00:00
|
|
|
$routes->group('', [
|
2021-08-23 11:05:16 +00:00
|
|
|
'namespace' => 'Modules\Fediverse\Controllers',
|
2022-09-28 14:00:05 +00:00
|
|
|
], static function ($routes): void {
|
2021-04-02 17:20:02 +00:00
|
|
|
// webfinger
|
|
|
|
$routes->get('.well-known/webfinger', 'WebFingerController', [
|
|
|
|
'as' => 'webfinger',
|
|
|
|
]);
|
2022-01-06 14:26:03 +00:00
|
|
|
// nodeInfo2
|
|
|
|
$routes->get('.well-known/x-nodeinfo2', 'NodeInfo2Controller', [
|
|
|
|
'as' => 'nodeInfo2',
|
|
|
|
]);
|
2021-04-02 17:20:02 +00:00
|
|
|
// Actor
|
2022-09-28 14:00:05 +00:00
|
|
|
$routes->group('@(:actorUsername)', static function ($routes): void {
|
2021-04-02 17:20:02 +00:00
|
|
|
// Actor
|
2023-08-27 13:26:06 +00:00
|
|
|
$routes->get('/', 'ActorController::index/$1', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'actor',
|
|
|
|
]);
|
|
|
|
$routes->post('inbox', 'ActorController::inbox/$1', [
|
2023-06-12 14:47:38 +00:00
|
|
|
'as' => 'inbox',
|
|
|
|
'filter' => 'fediverse:verify-activitystream,verify-blocks,verify-signature',
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
|
|
|
$routes->get('outbox', 'ActorController::outbox/$1', [
|
2023-06-12 14:47:38 +00:00
|
|
|
'as' => 'outbox',
|
2022-02-05 10:57:02 +00:00
|
|
|
'filter' => 'fediverse:verify-activitystream',
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
|
|
|
$routes->get('followers', 'ActorController::followers/$1', [
|
2023-06-12 14:47:38 +00:00
|
|
|
'as' => 'followers',
|
2022-02-05 10:57:02 +00:00
|
|
|
'filter' => 'fediverse::activity-stream',
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
|
|
|
$routes->post('follow', 'ActorController::attemptFollow/$1', [
|
|
|
|
'as' => 'attempt-follow',
|
|
|
|
]);
|
|
|
|
$routes->get('activities/(:uuid)', 'ActorController::activity/$1/$2', [
|
|
|
|
'as' => 'activity',
|
|
|
|
]);
|
|
|
|
});
|
2021-08-13 11:07:29 +00:00
|
|
|
// Post
|
2023-10-12 15:52:20 +00:00
|
|
|
$routes->post('posts/create', 'PostController::attemptCreate/$1', [
|
2021-08-13 11:07:29 +00:00
|
|
|
'as' => 'post-attempt-create',
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
2023-08-27 13:26:06 +00:00
|
|
|
$routes->get('posts/(:uuid)', 'PostController::index/$1', [
|
2021-08-13 11:07:29 +00:00
|
|
|
'as' => 'post',
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
2023-08-27 13:26:06 +00:00
|
|
|
$routes->get('posts/(:uuid)/replies', 'PostController::index/$1', [
|
2021-08-13 11:07:29 +00:00
|
|
|
'as' => 'post-replies',
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
|
|
|
$routes->post(
|
2021-08-13 11:07:29 +00:00
|
|
|
'posts/(:uuid)/remote/(:postAction)',
|
|
|
|
'PostController::attemptRemoteAction/$1/$2/$3',
|
2021-04-02 17:20:02 +00:00
|
|
|
[
|
2021-08-13 11:07:29 +00:00
|
|
|
'as' => 'post-attempt-remote-action',
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
);
|
|
|
|
// Blocking actors and domains
|
|
|
|
$routes->post(
|
|
|
|
'fediverse-block-actor',
|
|
|
|
'BlockController::attemptBlockActor',
|
2021-05-19 16:35:13 +00:00
|
|
|
[
|
|
|
|
'as' => 'fediverse-attempt-block-actor',
|
|
|
|
],
|
2021-04-02 17:20:02 +00:00
|
|
|
);
|
|
|
|
$routes->post(
|
|
|
|
'fediverse-block-domain',
|
|
|
|
'BlockController::attemptBlockDomain',
|
2021-05-19 16:35:13 +00:00
|
|
|
[
|
|
|
|
'as' => 'fediverse-attempt-block-domain',
|
|
|
|
],
|
2021-04-02 17:20:02 +00:00
|
|
|
);
|
|
|
|
$routes->post(
|
|
|
|
'fediverse-unblock-actor',
|
|
|
|
'BlockController::attemptUnblockActor',
|
|
|
|
[
|
|
|
|
'as' => 'fediverse-attempt-unblock-actor',
|
|
|
|
],
|
|
|
|
);
|
|
|
|
$routes->post(
|
|
|
|
'fediverse-unblock-domain',
|
|
|
|
'BlockController::attemptUnblockDomain',
|
|
|
|
[
|
|
|
|
'as' => 'fediverse-attempt-unblock-domain',
|
|
|
|
],
|
|
|
|
);
|
|
|
|
$routes->cli('scheduled-activities', 'SchedulerController::activity');
|
|
|
|
});
|