Commits (4)
# [1.0.0-alpha.77](https://code.podlibre.org/podlibre/castopod-host/compare/v1.0.0-alpha.76...v1.0.0-alpha.77) (2021-11-23)
### Bug Fixes
- **cors:** add preflight option routes for episode, podcast and status objects
([a281abf](https://code.podlibre.org/podlibre/castopod-host/commit/a281abfda475388a07943c169dab460cc2d4f944))
- **podcast-import:** move guid attribute declaration for Episode entity to
include slug data
([5d02ae3](https://code.podlibre.org/podlibre/castopod-host/commit/5d02ae39908a9d743627135b372bf981134c4328))
# [1.0.0-alpha.76](https://code.podlibre.org/podlibre/castopod-host/compare/v1.0.0-alpha.75...v1.0.0-alpha.76) (2021-10-26)
### Bug Fixes
......
......@@ -11,7 +11,7 @@ declare(strict_types=1);
|
| NOTE: this constant is updated upon release with Continuous Integration.
*/
defined('CP_VERSION') || define('CP_VERSION', '1.0.0-alpha.76');
defined('CP_VERSION') || define('CP_VERSION', '1.0.0-alpha.77');
/*
| --------------------------------------------------------------------
......
......@@ -690,6 +690,7 @@ $routes->group('@(:podcastName)', function ($routes): void {
'as' => 'podcast-activity',
]);
// override default ActivityPub Library's actor route
$routes->options('/', 'ActivityPubController::preflight');
$routes->get('/', 'PodcastController::activity/$1', [
'as' => 'actor',
'alternate-content' => [
......@@ -707,6 +708,7 @@ $routes->group('@(:podcastName)', function ($routes): void {
],
],
]);
$routes->options('episodes', 'ActivityPubController::preflight');
$routes->get('episodes', 'PodcastController::episodes/$1', [
'as' => 'podcast-episodes',
'alternate-content' => [
......@@ -722,6 +724,7 @@ $routes->group('@(:podcastName)', function ($routes): void {
],
]);
$routes->group('episodes/(:slug)', function ($routes): void {
$routes->options('/', 'ActivityPubController::preflight');
$routes->get('/', 'EpisodeController/$1/$2', [
'as' => 'episode',
'alternate-content' => [
......@@ -736,7 +739,7 @@ $routes->group('@(:podcastName)', function ($routes): void {
],
],
]);
$routes->options('comments', 'EpisodeController::commentsPreflight/$1/$2');
$routes->options('comments', 'ActivityPubController::preflight');
$routes->get('comments', 'EpisodeController::comments/$1/$2', [
'as' => 'episode-comments',
'application/activity+json' => [
......@@ -806,6 +809,7 @@ $routes->group('@(:podcastName)', function ($routes): void {
]);
// Status
$routes->group('statuses/(:uuid)', function ($routes): void {
$routes->options('/', 'ActivityPubController::preflight');
$routes->get('/', 'StatusController::view/$1/$2', [
'as' => 'status',
'alternate-content' => [
......@@ -819,6 +823,7 @@ $routes->group('@(:podcastName)', function ($routes): void {
],
],
]);
$routes->options('replies', 'ActivityPubController::preflight');
$routes->get('replies', 'StatusController/$1/$2', [
'as' => 'status-replies',
'alternate-content' => [
......
<?php
declare(strict_types=1);
/**
* @copyright 2021 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Controllers;
use CodeIgniter\Controller;
use CodeIgniter\HTTP\Response;
class ActivityPubController extends Controller
{
/**
* @noRector ReturnTypeDeclarationRector
*/
public function preflight(): Response
{
return $this->response->setHeader('Access-Control-Allow-Origin', '*') // for allowing any domain, insecure
->setHeader('Access-Control-Allow-Headers', '*') // for allowing any headers, insecure
->setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS') // allows GET and OPTIONS methods only
->setHeader('Access-Control-Max-Age', '86400')
->setHeader('Cache-Control', 'public, max-age=86400')
->setStatusCode(200);
}
}
......@@ -345,9 +345,9 @@ class PodcastImportController extends BaseController
$newEpisode = new Episode([
'podcast_id' => $newPodcastId,
'guid' => $item->guid ?? null,
'title' => $item->title,
'slug' => $slug,
'guid' => $item->guid ?? null,
'audio_file' => download_file((string) $item->enclosure->attributes()['url']),
'description_markdown' => $converter->convert($itemDescriptionHtml),
'description_html' => $itemDescriptionHtml,
......
......@@ -210,19 +210,6 @@ class EpisodeController extends BaseController
->setBody($podcastObject->toJSON());
}
/**
* @noRector ReturnTypeDeclarationRector
*/
public function commentsPreflight(): Response
{
return $this->response->setHeader('Access-Control-Allow-Origin', '*') // for allowing any domain, insecure
->setHeader('Access-Control-Allow-Headers', '*') // for allowing any headers, insecure
->setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS') // allows GET and OPTIONS methods only
->setHeader('Access-Control-Max-Age', '86400')
->setHeader('Cache-Control', 'public, max-age=86400')
->setStatusCode(200);
}
/**
* @noRector ReturnTypeDeclarationRector
*/
......
......@@ -420,7 +420,7 @@ class Episode extends Entity
public function getLink(): string
{
return base_url(route_to('episode', $this->getPodcast() ->name, $this->attributes['slug']));
return url_to('episode', $this->getPodcast()->name, $this->attributes['slug']);
}
public function getEmbeddablePlayerUrl(string $theme = null): string
......
......@@ -125,7 +125,7 @@ class FavouriteModel extends UuidModel
$likeActivity = new LikeActivity();
$likeActivity
->set('id', base_url(route_to('activity', $actor->username, $activity->id)))
->set('id', url_to('activity', $actor->username, $activity->id))
->set('actor', $actor->uri)
->set('object', $status->uri);
......
......@@ -83,7 +83,7 @@ class FollowModel extends Model
'queued',
);
$followActivity->set('id', base_url(route_to('activity', $actor->username, $activityId)));
$followActivity->set('id', url_to('activity', $actor->username, $activityId));
model('ActivityModel')
->update($activityId, [
......
......@@ -278,7 +278,7 @@ class StatusModel extends UuidModel
if ($registerActivity) {
// set status id and uri to construct NoteObject
$status->id = $newStatusId;
$status->uri = base_url(route_to('status', $status->actor->username, $newStatusId));
$status->uri = url_to('status', $status->actor->username, $newStatusId);
$createActivity = new CreateActivity();
$noteObjectClass = config('ActivityPub')
......@@ -298,7 +298,7 @@ class StatusModel extends UuidModel
'queued',
);
$createActivity->set('id', base_url(route_to('activity', $status->actor->username, $activityId)));
$createActivity->set('id', url_to('activity', $status->actor->username, $activityId));
model('ActivityModel')
->update($activityId, [
......@@ -411,7 +411,7 @@ class StatusModel extends UuidModel
'queued',
);
$deleteActivity->set('id', base_url(route_to('activity', $status->actor->username, $activityId)));
$deleteActivity->set('id', url_to('activity', $status->actor->username, $activityId));
model('ActivityModel')
->update($activityId, [
......@@ -492,7 +492,7 @@ class StatusModel extends UuidModel
'queued',
);
$announceActivity->set('id', base_url(route_to('activity', $status->actor->username, $activityId)));
$announceActivity->set('id', url_to('activity', $status->actor->username, $activityId));
model('ActivityModel')
->update($activityId, [
......@@ -535,10 +535,7 @@ class StatusModel extends UuidModel
->first();
$announceActivity = new AnnounceActivity($reblogStatus);
$announceActivity->set(
'id',
base_url(route_to('activity', $reblogStatus->actor->username, $activity->id)),
);
$announceActivity->set('id', url_to('activity', $reblogStatus->actor->username, $activity->id),);
$undoActivity
->set('actor', $reblogStatus->actor->uri)
......@@ -555,7 +552,7 @@ class StatusModel extends UuidModel
'queued',
);
$undoActivity->set('id', base_url(route_to('activity', $reblogStatus->actor->username, $activityId)));
$undoActivity->set('id', url_to('activity', $reblogStatus->actor->username, $activityId));
model('ActivityModel')
->update($activityId, [
......@@ -627,7 +624,7 @@ class StatusModel extends UuidModel
$actor = model('ActorModel')
->getActorById((int) $data['data']['actor_id']);
$data['data']['uri'] = base_url(route_to('status', $actor->username, $uuid4->toString()));
$data['data']['uri'] = url_to('status', $actor->username, $uuid4->toString());
}
return $data;
......
{
"name": "podlibre/castopod-host",
"version": "1.0.0-alpha76",
"version": "1.0.0-alpha77",
"type": "project",
"description": "Castopod Host is an open-source hosting platform made for podcasters who want engage and interact with their audience.",
"homepage": "https://castopod.org",
......
This diff is collapsed.
{
"name": "castopod-host",
"version": "1.0.0-alpha.76",
"version": "1.0.0-alpha.77",
"description": "Castopod Host is an open-source hosting platform made for podcasters who want engage and interact with their audience.",
"private": true,
"license": "AGPL-3.0-or-later",
......@@ -45,10 +45,10 @@
"devDependencies": {
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/exec": "^5.0.0",
"@semantic-release/git": "^9.0.0",
"@semantic-release/gitlab": "^6.0.9",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/exec": "^6.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/gitlab": "^7.0.4",
"@tailwindcss/forms": "^0.2.1",
"@tailwindcss/line-clamp": "^0.2.0",
"@tailwindcss/typography": "^0.4.0",
......@@ -72,7 +72,7 @@
"prettier": "2.2.1",
"prettier-plugin-organize-imports": "^1.1.1",
"rollup-plugin-multi-input": "^1.2.0",
"semantic-release": "^17.4.2",
"semantic-release": "^18.0.0",
"stylelint": "^13.12.0",
"stylelint-config-standard": "^21.0.0",
"svgo": "^2.2.2",
......