Newer
Older
<?php

Yassine Doghri
committed
declare(strict_types=1);
/**
* @copyright 2021 Ad Aures
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/

Yassine Doghri
committed
$routes = service('routes');
// FIXME: HOTFIX to be edited, add character to actorUsername regex to have it show up on routes list
// This bug is from CI4, since v4.2.8 with the following change
// https://github.com/codeigniter4/CodeIgniter4/pull/6644/files#diff-b28efb4cd802e8a3ead515befe9f46254b6cc9d17ab1beeb8a42a16cff69d283R1257
$routes->addPlaceholder('actorUsername', '[a-zA-Z0-9\_]{1,33}');
$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}',
);
$routes->addPlaceholder('postAction', '\bfavourite|\breblog|\breply');
/**

Yassine Doghri
committed
* Fediverse routes file
*/
$routes->group('', [

Yassine Doghri
committed
'namespace' => 'Modules\Fediverse\Controllers',
], static function ($routes): void {
// webfinger
$routes->get('.well-known/webfinger', 'WebFingerController', [
'as' => 'webfinger',
]);

Yassine Doghri
committed
// nodeInfo2
$routes->get('.well-known/x-nodeinfo2', 'NodeInfo2Controller', [
'as' => 'nodeInfo2',
]);
// Actor
$routes->group('@(:actorUsername)', static function ($routes): void {
// Actor
$routes->get('/', 'ActorController/$1', [
'as' => 'actor',
]);
$routes->post('inbox', 'ActorController::inbox/$1', [
'as' => 'inbox',
'filter' =>

Yassine Doghri
committed
'fediverse:verify-activitystream,verify-blocks,verify-signature',
]);
$routes->get('outbox', 'ActorController::outbox/$1', [
'as' => 'outbox',

Yassine Doghri
committed
'filter' => 'fediverse:verify-activitystream',
]);
$routes->get('followers', 'ActorController::followers/$1', [
'as' => 'followers',

Yassine Doghri
committed
'filter' => 'fediverse::activity-stream',
]);
$routes->post('follow', 'ActorController::attemptFollow/$1', [
'as' => 'attempt-follow',
]);
$routes->get('activities/(:uuid)', 'ActorController::activity/$1/$2', [
'as' => 'activity',
]);
});
// Post
$routes->post('posts/new', 'PostController::attemptCreate/$1', [
'as' => 'post-attempt-create',
]);
$routes->get('posts/(:uuid)', 'PostController/$1', [
'as' => 'post',
]);
$routes->get('posts/(:uuid)/replies', 'PostController/$1', [
'as' => 'post-replies',
]);
$routes->post(
'posts/(:uuid)/remote/(:postAction)',
'PostController::attemptRemoteAction/$1/$2/$3',
[
'as' => 'post-attempt-remote-action',
],
);
// Blocking actors and domains
$routes->post(
'fediverse-block-actor',
'BlockController::attemptBlockActor',
[
'as' => 'fediverse-attempt-block-actor',
],
);
$routes->post(
'fediverse-block-domain',
'BlockController::attemptBlockDomain',
[
'as' => 'fediverse-attempt-block-domain',
],
);
$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');
});