Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • adaures/castopod
  • mkljczk/castopod-host
  • spaetz/castopod-host
  • PatrykMis/castopod
  • jonas/castopod
  • ajeremias/castopod
  • misuzu/castopod
  • KrzysztofDomanczyk/castopod
  • Behel/castopod
  • nebulon/castopod
  • ewen/castopod
  • NeoluxConsulting/castopod
  • nateritter/castopod-og
  • prcutler/castopod
14 results
Show changes
Showing
with 353 additions and 178 deletions
...@@ -16,30 +16,23 @@ use App\Models\EpisodeModel; ...@@ -16,30 +16,23 @@ use App\Models\EpisodeModel;
use App\Models\PodcastModel; use App\Models\PodcastModel;
use CodeIgniter\Controller; use CodeIgniter\Controller;
use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Config\Services; use CodeIgniter\HTTP\URI;
use Modules\Analytics\Config\Analytics; use Modules\Analytics\Config\Analytics;
use Modules\PremiumPodcasts\Entities\Subscription; use Modules\PremiumPodcasts\Entities\Subscription;
use Modules\PremiumPodcasts\Models\SubscriptionModel; use Modules\PremiumPodcasts\Models\SubscriptionModel;
use Override;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class EpisodeAudioController extends Controller class EpisodeAudioController extends Controller
{ {
/**
* Instance of the main Request object.
*
* @var IncomingRequest
*/
protected $request;
/** /**
* An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all * An array of helpers to be loaded automatically upon class instantiation. These helpers will be available to all
* other controllers that extend Analytics. * other controllers that extend Analytics.
* *
* @var string[] * @var list<string>
*/ */
protected $helpers = ['analytics']; protected $helpers = ['analytics'];
...@@ -49,13 +42,11 @@ class EpisodeAudioController extends Controller ...@@ -49,13 +42,11 @@ class EpisodeAudioController extends Controller
protected Analytics $analyticsConfig; protected Analytics $analyticsConfig;
/** #[Override]
* Constructor.
*/
public function initController( public function initController(
RequestInterface $request, RequestInterface $request,
ResponseInterface $response, ResponseInterface $response,
LoggerInterface $logger LoggerInterface $logger,
): void { ): void {
// Do Not Edit This Line // Do Not Edit This Line
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
...@@ -102,7 +93,7 @@ class EpisodeAudioController extends Controller ...@@ -102,7 +93,7 @@ class EpisodeAudioController extends Controller
// check if podcast is already unlocked before any token validation // check if podcast is already unlocked before any token validation
if ($this->episode->is_premium && ! ($subscription = service('premium_podcasts')->subscription( if ($this->episode->is_premium && ! ($subscription = service('premium_podcasts')->subscription(
$this->episode->podcast->handle $this->episode->podcast->handle,
)) instanceof Subscription) { )) instanceof Subscription) {
// look for token as GET parameter // look for token as GET parameter
if (($token = $this->request->getGet('token')) === null) { if (($token = $this->request->getGet('token')) === null) {
...@@ -119,7 +110,7 @@ class EpisodeAudioController extends Controller ...@@ -119,7 +110,7 @@ class EpisodeAudioController extends Controller
// check if there's a valid subscription for the provided token // check if there's a valid subscription for the provided token
if (! ($subscription = (new SubscriptionModel())->validateSubscription( if (! ($subscription = (new SubscriptionModel())->validateSubscription(
$this->episode->podcast->handle, $this->episode->podcast->handle,
$token $token,
)) instanceof Subscription) { )) instanceof Subscription) {
return $this->response->setStatusCode(401, 'Invalid token!') return $this->response->setStatusCode(401, 'Invalid token!')
->setJSON([ ->setJSON([
...@@ -132,7 +123,7 @@ class EpisodeAudioController extends Controller ...@@ -132,7 +123,7 @@ class EpisodeAudioController extends Controller
} }
} }
$session = Services::session(); $session = service('session');
$serviceName = ''; $serviceName = '';
if ($this->request->getGet('_from')) { if ($this->request->getGet('_from')) {
...@@ -163,9 +154,21 @@ class EpisodeAudioController extends Controller ...@@ -163,9 +154,21 @@ class EpisodeAudioController extends Controller
$audioDuration, $audioDuration,
$this->episode->published_at->getTimestamp(), $this->episode->published_at->getTimestamp(),
$serviceName, $serviceName,
$subscription instanceof Subscription ? $subscription->id : null $subscription instanceof Subscription ? $subscription->id : null,
); );
return redirect()->to($this->analyticsConfig->getAudioUrl($this->episode, $this->request->getGet())); $audioFileURI = new URI(service('file_manager')->getUrl($this->episode->audio->file_key));
$queryParams = [];
foreach ($this->request->getGet() as $key => $value) {
// do not include token in query params
if ($key !== 'token') {
$queryParams[$key] = $value;
}
}
$audioFileURI->setQueryArray($queryParams);
return redirect()->to((string) $audioFileURI);
} }
} }
...@@ -16,11 +16,10 @@ use App\Entities\Podcast; ...@@ -16,11 +16,10 @@ use App\Entities\Podcast;
use App\Libraries\CommentObject; use App\Libraries\CommentObject;
use App\Models\EpisodeCommentModel; use App\Models\EpisodeCommentModel;
use App\Models\EpisodeModel; use App\Models\EpisodeModel;
use App\Models\LikeModel;
use App\Models\PodcastModel; use App\Models\PodcastModel;
use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface;
use Modules\Analytics\AnalyticsTrait; use Modules\Analytics\AnalyticsTrait;
use Modules\Fediverse\Entities\Actor; use Modules\Fediverse\Entities\Actor;
use Modules\Fediverse\Objects\OrderedCollectionObject; use Modules\Fediverse\Objects\OrderedCollectionObject;
...@@ -78,10 +77,7 @@ class EpisodeCommentController extends BaseController ...@@ -78,10 +77,7 @@ class EpisodeCommentController extends BaseController
public function view(): string public function view(): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->podcast->id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->podcast->id);
}
$cacheName = implode( $cacheName = implode(
'_', '_',
...@@ -97,12 +93,12 @@ class EpisodeCommentController extends BaseController ...@@ -97,12 +93,12 @@ class EpisodeCommentController extends BaseController
); );
if (! ($cachedView = cache($cacheName))) { if (! ($cachedView = cache($cacheName))) {
set_episode_comment_metatags($this->comment);
$data = [ $data = [
'metatags' => get_episode_comment_metatags($this->comment), 'podcast' => $this->podcast,
'podcast' => $this->podcast, 'actor' => $this->actor,
'actor' => $this->actor, 'episode' => $this->episode,
'episode' => $this->episode, 'comment' => $this->comment,
'comment' => $this->comment,
]; ];
// if user is logged in then send to the authenticated activity view // if user is logged in then send to the authenticated activity view
...@@ -120,7 +116,7 @@ class EpisodeCommentController extends BaseController ...@@ -120,7 +116,7 @@ class EpisodeCommentController extends BaseController
return $cachedView; return $cachedView;
} }
public function commentObject(): Response public function commentObject(): ResponseInterface
{ {
$commentObject = new CommentObject($this->comment); $commentObject = new CommentObject($this->comment);
...@@ -129,7 +125,7 @@ class EpisodeCommentController extends BaseController ...@@ -129,7 +125,7 @@ class EpisodeCommentController extends BaseController
->setBody($commentObject->toJSON()); ->setBody($commentObject->toJSON());
} }
public function replies(): Response public function replies(): ResponseInterface
{ {
/** /**
* get comment replies * get comment replies
...@@ -164,25 +160,25 @@ class EpisodeCommentController extends BaseController ...@@ -164,25 +160,25 @@ class EpisodeCommentController extends BaseController
->setBody($collection->toJSON()); ->setBody($collection->toJSON());
} }
public function attemptLike(): RedirectResponse public function likeAction(): RedirectResponse
{ {
if (! ($interactAsActor = interact_as_actor()) instanceof Actor) { if (! ($interactAsActor = interact_as_actor()) instanceof Actor) {
return redirect()->back(); return redirect()->back();
} }
model(LikeModel::class) model('LikeModel')
->toggleLike($interactAsActor, $this->comment); ->toggleLike($interactAsActor, $this->comment);
return redirect()->back(); return redirect()->back();
} }
public function attemptReply(): RedirectResponse public function replyAction(): RedirectResponse
{ {
if (! ($interactAsActor = interact_as_actor()) instanceof Actor) { if (! ($interactAsActor = interact_as_actor()) instanceof Actor) {
return redirect()->back(); return redirect()->back();
} }
model(LikeModel::class) model('LikeModel')
->toggleLike($interactAsActor, $this->comment); ->toggleLike($interactAsActor, $this->comment);
return redirect()->back(); return redirect()->back();
......
...@@ -16,17 +16,14 @@ use App\Libraries\NoteObject; ...@@ -16,17 +16,14 @@ use App\Libraries\NoteObject;
use App\Libraries\PodcastEpisode; use App\Libraries\PodcastEpisode;
use App\Models\EpisodeModel; use App\Models\EpisodeModel;
use App\Models\PodcastModel; use App\Models\PodcastModel;
use App\Models\PostModel;
use CodeIgniter\Database\BaseBuilder; use CodeIgniter\Database\BaseBuilder;
use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\Response;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Config\Embed; use Config\Embed;
use Config\Images;
use Config\Services;
use Modules\Analytics\AnalyticsTrait; use Modules\Analytics\AnalyticsTrait;
use Modules\Fediverse\Objects\OrderedCollectionObject; use Modules\Fediverse\Objects\OrderedCollectionObject;
use Modules\Fediverse\Objects\OrderedCollectionPage; use Modules\Fediverse\Objects\OrderedCollectionPage;
use Modules\Media\FileManagers\FileManagerInterface;
use SimpleXMLElement; use SimpleXMLElement;
class EpisodeController extends BaseController class EpisodeController extends BaseController
...@@ -67,10 +64,7 @@ class EpisodeController extends BaseController ...@@ -67,10 +64,7 @@ class EpisodeController extends BaseController
public function index(): string public function index(): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->episode->podcast_id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->episode->podcast_id);
}
$cacheName = implode( $cacheName = implode(
'_', '_',
...@@ -87,10 +81,10 @@ class EpisodeController extends BaseController ...@@ -87,10 +81,10 @@ class EpisodeController extends BaseController
); );
if (! ($cachedView = cache($cacheName))) { if (! ($cachedView = cache($cacheName))) {
set_episode_metatags($this->episode);
$data = [ $data = [
'metatags' => get_episode_metatags($this->episode), 'podcast' => $this->podcast,
'podcast' => $this->podcast, 'episode' => $this->episode,
'episode' => $this->episode,
]; ];
$secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode( $secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode(
...@@ -105,9 +99,7 @@ class EpisodeController extends BaseController ...@@ -105,9 +99,7 @@ class EpisodeController extends BaseController
// The page cache is set to a decade so it is deleted manually upon podcast update // The page cache is set to a decade so it is deleted manually upon podcast update
return view('episode/comments', $data, [ return view('episode/comments', $data, [
'cache' => $secondsToNextUnpublishedEpisode 'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
? $secondsToNextUnpublishedEpisode
: DECADE,
'cache_name' => $cacheName, 'cache_name' => $cacheName,
]); ]);
} }
...@@ -117,10 +109,7 @@ class EpisodeController extends BaseController ...@@ -117,10 +109,7 @@ class EpisodeController extends BaseController
public function activity(): string public function activity(): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->episode->podcast_id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->episode->podcast_id);
}
$cacheName = implode( $cacheName = implode(
'_', '_',
...@@ -138,10 +127,10 @@ class EpisodeController extends BaseController ...@@ -138,10 +127,10 @@ class EpisodeController extends BaseController
); );
if (! ($cachedView = cache($cacheName))) { if (! ($cachedView = cache($cacheName))) {
set_episode_metatags($this->episode);
$data = [ $data = [
'metatags' => get_episode_metatags($this->episode), 'podcast' => $this->podcast,
'podcast' => $this->podcast, 'episode' => $this->episode,
'episode' => $this->episode,
]; ];
$secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode( $secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode(
...@@ -156,9 +145,124 @@ class EpisodeController extends BaseController ...@@ -156,9 +145,124 @@ class EpisodeController extends BaseController
// The page cache is set to a decade so it is deleted manually upon podcast update // The page cache is set to a decade so it is deleted manually upon podcast update
return view('episode/activity', $data, [ return view('episode/activity', $data, [
'cache' => $secondsToNextUnpublishedEpisode 'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
? $secondsToNextUnpublishedEpisode 'cache_name' => $cacheName,
: DECADE, ]);
}
return $cachedView;
}
public function chapters(): string
{
$this->registerPodcastWebpageHit($this->episode->podcast_id);
$cacheName = implode(
'_',
array_filter([
'page',
"podcast#{$this->podcast->id}",
"episode#{$this->episode->id}",
'chapters',
service('request')
->getLocale(),
is_unlocked($this->podcast->handle) ? 'unlocked' : null,
auth()
->loggedIn() ? 'authenticated' : null,
]),
);
if (! ($cachedView = cache($cacheName))) {
set_episode_metatags($this->episode);
$data = [
'podcast' => $this->podcast,
'episode' => $this->episode,
];
// get chapters from json file
if (isset($this->episode->chapters->file_key)) {
/** @var FileManagerInterface $fileManager */
$fileManager = service('file_manager');
$episodeChaptersJsonString = (string) $fileManager->getFileContents($this->episode->chapters->file_key);
$chapters = json_decode($episodeChaptersJsonString, true);
$data['chapters'] = $chapters;
}
$secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode(
$this->podcast->id,
);
if (auth()->loggedIn()) {
helper('form');
return view('episode/chapters', $data);
}
// The page cache is set to a decade so it is deleted manually upon podcast update
return view('episode/chapters', $data, [
'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
'cache_name' => $cacheName,
]);
}
return $cachedView;
}
public function transcript(): string
{
$this->registerPodcastWebpageHit($this->episode->podcast_id);
$cacheName = implode(
'_',
array_filter([
'page',
"podcast#{$this->podcast->id}",
"episode#{$this->episode->id}",
'transcript',
service('request')
->getLocale(),
is_unlocked($this->podcast->handle) ? 'unlocked' : null,
auth()
->loggedIn() ? 'authenticated' : null,
]),
);
if (! ($cachedView = cache($cacheName))) {
set_episode_metatags($this->episode);
$data = [
'podcast' => $this->podcast,
'episode' => $this->episode,
];
// get transcript from json file
if ($this->episode->transcript !== null) {
$data['transcript'] = $this->episode->transcript;
if ($this->episode->transcript->json_key !== null) {
/** @var FileManagerInterface $fileManager */
$fileManager = service('file_manager');
$transcriptJsonString = (string) $fileManager->getFileContents(
$this->episode->transcript->json_key,
);
$data['captions'] = json_decode($transcriptJsonString, true);
}
}
$secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode(
$this->podcast->id,
);
if (auth()->loggedIn()) {
helper('form');
return view('episode/transcript', $data);
}
// The page cache is set to a decade so it is deleted manually upon podcast update
return view('episode/transcript', $data, [
'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
'cache_name' => $cacheName, 'cache_name' => $cacheName,
]); ]);
} }
...@@ -170,12 +274,9 @@ class EpisodeController extends BaseController ...@@ -170,12 +274,9 @@ class EpisodeController extends BaseController
{ {
header('Content-Security-Policy: frame-ancestors http://*:* https://*:*'); header('Content-Security-Policy: frame-ancestors http://*:* https://*:*');
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->episode->podcast_id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->episode->podcast_id);
}
$session = Services::session(); $session = service('session');
if (service('superglobals')->server('HTTP_REFERER') !== null) { if (service('superglobals')->server('HTTP_REFERER') !== null) {
$session->set('embed_domain', parse_url(service('superglobals')->server('HTTP_REFERER'), PHP_URL_HOST)); $session->set('embed_domain', parse_url(service('superglobals')->server('HTTP_REFERER'), PHP_URL_HOST));
...@@ -211,9 +312,7 @@ class EpisodeController extends BaseController ...@@ -211,9 +312,7 @@ class EpisodeController extends BaseController
// The page cache is set to a decade so it is deleted manually upon podcast update // The page cache is set to a decade so it is deleted manually upon podcast update
return view('embed', $data, [ return view('embed', $data, [
'cache' => $secondsToNextUnpublishedEpisode 'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
? $secondsToNextUnpublishedEpisode
: DECADE,
'cache_name' => $cacheName, 'cache_name' => $cacheName,
]); ]);
} }
...@@ -233,15 +332,15 @@ class EpisodeController extends BaseController ...@@ -233,15 +332,15 @@ class EpisodeController extends BaseController
'author_url' => $this->podcast->link, 'author_url' => $this->podcast->link,
'html' => '<iframe src="' . 'html' => '<iframe src="' .
$this->episode->embed_url . $this->episode->embed_url .
'" width="100%" height="' . config(Embed::class)->height . '" frameborder="0" scrolling="no"></iframe>', '" width="100%" height="' . config('Embed')->height . '" frameborder="0" scrolling="no"></iframe>',
'width' => config(Embed::class) 'width' => config('Embed')
->width, ->width,
'height' => config(Embed::class) 'height' => config('Embed')
->height, ->height,
'thumbnail_url' => $this->episode->cover->og_url, 'thumbnail_url' => $this->episode->cover->og_url,
'thumbnail_width' => config(Images::class) 'thumbnail_width' => config('Images')
->podcastCoverSizes['og']['width'], ->podcastCoverSizes['og']['width'],
'thumbnail_height' => config(Images::class) 'thumbnail_height' => config('Images')
->podcastCoverSizes['og']['height'], ->podcastCoverSizes['og']['height'],
]); ]);
} }
...@@ -258,26 +357,26 @@ class EpisodeController extends BaseController ...@@ -258,26 +357,26 @@ class EpisodeController extends BaseController
$oembed->addChild('author_name', $this->podcast->title); $oembed->addChild('author_name', $this->podcast->title);
$oembed->addChild('author_url', $this->podcast->link); $oembed->addChild('author_url', $this->podcast->link);
$oembed->addChild('thumbnail', $this->episode->cover->og_url); $oembed->addChild('thumbnail', $this->episode->cover->og_url);
$oembed->addChild('thumbnail_width', (string) config(Images::class)->podcastCoverSizes['og']['width']); $oembed->addChild('thumbnail_width', (string) config('Images')->podcastCoverSizes['og']['width']);
$oembed->addChild('thumbnail_height', (string) config(Images::class)->podcastCoverSizes['og']['height']); $oembed->addChild('thumbnail_height', (string) config('Images')->podcastCoverSizes['og']['height']);
$oembed->addChild( $oembed->addChild(
'html', 'html',
htmlspecialchars( htmlspecialchars(
'<iframe src="' . '<iframe src="' .
$this->episode->embed_url . $this->episode->embed_url .
'" width="100%" height="' . config( '" width="100%" height="' . config(
Embed::class Embed::class,
)->height . '" frameborder="0" scrolling="no"></iframe>', )->height . '" frameborder="0" scrolling="no"></iframe>',
), ),
); );
$oembed->addChild('width', (string) config(Embed::class)->width); $oembed->addChild('width', (string) config('Embed')->width);
$oembed->addChild('height', (string) config(Embed::class)->height); $oembed->addChild('height', (string) config('Embed')->height);
// @phpstan-ignore-next-line // @phpstan-ignore-next-line
return $this->response->setXML($oembed); return $this->response->setXML($oembed);
} }
public function episodeObject(): Response public function episodeObject(): ResponseInterface
{ {
$podcastObject = new PodcastEpisode($this->episode); $podcastObject = new PodcastEpisode($this->episode);
...@@ -286,17 +385,15 @@ class EpisodeController extends BaseController ...@@ -286,17 +385,15 @@ class EpisodeController extends BaseController
->setBody($podcastObject->toJSON()); ->setBody($podcastObject->toJSON());
} }
public function comments(): Response public function comments(): ResponseInterface
{ {
/** /**
* get comments: aggregated replies from posts referring to the episode * get comments: aggregated replies from posts referring to the episode
*/ */
$episodeComments = model(PostModel::class) $episodeComments = model('PostModel')
->whereIn('in_reply_to_id', function (BaseBuilder $builder): BaseBuilder { ->whereIn('in_reply_to_id', fn (BaseBuilder $builder): BaseBuilder => $builder->select('id')
return $builder->select('id') ->from('fediverse_posts')
->from('fediverse_posts') ->where('episode_id', $this->episode->id))
->where('episode_id', $this->episode->id);
})
->where('`published_at` <= UTC_TIMESTAMP()', null, false) ->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->orderBy('published_at', 'ASC'); ->orderBy('published_at', 'ASC');
......
...@@ -13,7 +13,7 @@ namespace App\Controllers; ...@@ -13,7 +13,7 @@ namespace App\Controllers;
use App\Entities\Episode; use App\Entities\Episode;
use App\Models\EpisodeModel; use App\Models\EpisodeModel;
use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse; use Modules\Media\FileManagers\FileManagerInterface;
class EpisodePreviewController extends BaseController class EpisodePreviewController extends BaseController
{ {
...@@ -44,7 +44,7 @@ class EpisodePreviewController extends BaseController ...@@ -44,7 +44,7 @@ class EpisodePreviewController extends BaseController
return $this->{$method}(...$params); return $this->{$method}(...$params);
} }
public function index(): RedirectResponse | string public function index(): string
{ {
helper('form'); helper('form');
...@@ -54,7 +54,7 @@ class EpisodePreviewController extends BaseController ...@@ -54,7 +54,7 @@ class EpisodePreviewController extends BaseController
]); ]);
} }
public function activity(): RedirectResponse | string public function activity(): string
{ {
helper('form'); helper('form');
...@@ -63,4 +63,50 @@ class EpisodePreviewController extends BaseController ...@@ -63,4 +63,50 @@ class EpisodePreviewController extends BaseController
'episode' => $this->episode, 'episode' => $this->episode,
]); ]);
} }
public function chapters(): string
{
$data = [
'podcast' => $this->episode->podcast,
'episode' => $this->episode,
];
if (isset($this->episode->chapters->file_key)) {
/** @var FileManagerInterface $fileManager */
$fileManager = service('file_manager');
$episodeChaptersJsonString = (string) $fileManager->getFileContents($this->episode->chapters->file_key);
$chapters = json_decode($episodeChaptersJsonString, true);
$data['chapters'] = $chapters;
}
helper('form');
return view('episode/preview-chapters', $data);
}
public function transcript(): string
{
// get transcript from json file
$data = [
'podcast' => $this->episode->podcast,
'episode' => $this->episode,
];
if ($this->episode->transcript !== null) {
$data['transcript'] = $this->episode->transcript;
if ($this->episode->transcript->json_key !== null) {
/** @var FileManagerInterface $fileManager */
$fileManager = service('file_manager');
$transcriptJsonString = (string) $fileManager->getFileContents(
$this->episode->transcript->json_key,
);
$data['captions'] = json_decode($transcriptJsonString, true);
}
}
helper('form');
return view('episode/preview-transcript', $data);
}
} }
...@@ -33,14 +33,25 @@ class FeedController extends Controller ...@@ -33,14 +33,25 @@ class FeedController extends Controller
public function index(string $podcastHandle): ResponseInterface public function index(string $podcastHandle): ResponseInterface
{ {
helper(['rss', 'premium_podcasts', 'misc']);
$podcast = (new PodcastModel())->where('handle', $podcastHandle) $podcast = (new PodcastModel())->where('handle', $podcastHandle)
->first(); ->first();
if (! $podcast instanceof Podcast) { if (! $podcast instanceof Podcast) {
throw PageNotFoundException::forPageNotFound(); throw PageNotFoundException::forPageNotFound();
} }
// 301 redirect to new feed?
$redirectToNewFeed = service('settings')
->get('Podcast.redirect_to_new_feed', 'podcast:' . $podcast->id);
if ($redirectToNewFeed && $podcast->new_feed_url !== null && filter_var(
$podcast->new_feed_url,
FILTER_VALIDATE_URL,
) && $podcast->new_feed_url !== current_url()) {
return redirect()->to($podcast->new_feed_url, 301);
}
helper(['rss', 'premium_podcasts', 'misc']);
$service = null; $service = null;
try { try {
$service = UserAgentsRSS::find(service('superglobals')->server('HTTP_USER_AGENT')); $service = UserAgentsRSS::find(service('superglobals')->server('HTTP_USER_AGENT'));
...@@ -66,7 +77,7 @@ class FeedController extends Controller ...@@ -66,7 +77,7 @@ class FeedController extends Controller
"podcast#{$podcast->id}", "podcast#{$podcast->id}",
'feed', 'feed',
$service ? $serviceSlug : null, $service ? $serviceSlug : null,
$subscription instanceof Subscription ? 'unlocked' : null, $subscription instanceof Subscription ? "subscription#{$subscription->id}" : null,
]), ]),
); );
...@@ -79,13 +90,7 @@ class FeedController extends Controller ...@@ -79,13 +90,7 @@ class FeedController extends Controller
); );
cache() cache()
->save( ->save($cacheName, $found, $secondsToNextUnpublishedEpisode ?: DECADE);
$cacheName,
$found,
$secondsToNextUnpublishedEpisode
? $secondsToNextUnpublishedEpisode
: DECADE,
);
} }
return $this->response->setXML($found); return $this->response->setXML($found);
......
...@@ -14,7 +14,6 @@ use App\Models\PodcastModel; ...@@ -14,7 +14,6 @@ use App\Models\PodcastModel;
use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Config\Cache;
use Modules\Media\FileManagers\FileManagerInterface; use Modules\Media\FileManagers\FileManagerInterface;
class HomeController extends BaseController class HomeController extends BaseController
...@@ -23,7 +22,7 @@ class HomeController extends BaseController ...@@ -23,7 +22,7 @@ class HomeController extends BaseController
{ {
$sortOptions = ['activity', 'created_desc', 'created_asc']; $sortOptions = ['activity', 'created_desc', 'created_asc'];
$sortBy = in_array($this->request->getGet('sort'), $sortOptions, true) ? $this->request->getGet( $sortBy = in_array($this->request->getGet('sort'), $sortOptions, true) ? $this->request->getGet(
'sort' 'sort',
) : 'activity'; ) : 'activity';
$allPodcasts = (new PodcastModel())->getAllPodcasts($sortBy); $allPodcasts = (new PodcastModel())->getAllPodcasts($sortBy);
...@@ -33,9 +32,9 @@ class HomeController extends BaseController ...@@ -33,9 +32,9 @@ class HomeController extends BaseController
return redirect()->route('podcast-activity', [$allPodcasts[0]->handle]); return redirect()->route('podcast-activity', [$allPodcasts[0]->handle]);
} }
set_home_metatags();
// default behavior: list all podcasts on home page // default behavior: list all podcasts on home page
$data = [ $data = [
'metatags' => get_home_metatags(),
'podcasts' => $allPodcasts, 'podcasts' => $allPodcasts,
'sortBy' => $sortBy, 'sortBy' => $sortBy,
]; ];
...@@ -54,7 +53,7 @@ class HomeController extends BaseController ...@@ -54,7 +53,7 @@ class HomeController extends BaseController
} }
// --- Can Castopod connect to the cache handler // --- Can Castopod connect to the cache handler
if (config(Cache::class)->handler !== 'dummy' && cache()->getCacheInfo() === null) { if (config('Cache')->handler !== 'dummy' && cache()->getCacheInfo() === null) {
$errors[] = 'Unable connect to the cache handler.'; $errors[] = 'Unable connect to the cache handler.';
} }
......
...@@ -49,9 +49,9 @@ class PageController extends BaseController ...@@ -49,9 +49,9 @@ class PageController extends BaseController
); );
if (! ($found = cache($cacheName))) { if (! ($found = cache($cacheName))) {
set_page_metatags($this->page);
$data = [ $data = [
'metatags' => get_page_metatags($this->page), 'page' => $this->page,
'page' => $this->page,
]; ];
$found = view('pages/page', $data); $found = view('pages/page', $data);
......
...@@ -17,7 +17,7 @@ use App\Models\EpisodeModel; ...@@ -17,7 +17,7 @@ use App\Models\EpisodeModel;
use App\Models\PodcastModel; use App\Models\PodcastModel;
use App\Models\PostModel; use App\Models\PostModel;
use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\Response; use CodeIgniter\HTTP\ResponseInterface;
use Modules\Analytics\AnalyticsTrait; use Modules\Analytics\AnalyticsTrait;
use Modules\Fediverse\Objects\OrderedCollectionObject; use Modules\Fediverse\Objects\OrderedCollectionObject;
use Modules\Fediverse\Objects\OrderedCollectionPage; use Modules\Fediverse\Objects\OrderedCollectionPage;
...@@ -47,7 +47,7 @@ class PodcastController extends BaseController ...@@ -47,7 +47,7 @@ class PodcastController extends BaseController
return $this->{$method}(...$params); return $this->{$method}(...$params);
} }
public function podcastActor(): Response public function podcastActor(): ResponseInterface
{ {
$podcastActor = new PodcastActor($this->podcast); $podcastActor = new PodcastActor($this->podcast);
...@@ -58,10 +58,7 @@ class PodcastController extends BaseController ...@@ -58,10 +58,7 @@ class PodcastController extends BaseController
public function activity(): string public function activity(): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->podcast->id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->podcast->id);
}
$cacheName = implode( $cacheName = implode(
'_', '_',
...@@ -78,10 +75,10 @@ class PodcastController extends BaseController ...@@ -78,10 +75,10 @@ class PodcastController extends BaseController
); );
if (! ($cachedView = cache($cacheName))) { if (! ($cachedView = cache($cacheName))) {
set_podcast_metatags($this->podcast, 'activity');
$data = [ $data = [
'metatags' => get_podcast_metatags($this->podcast, 'activity'), 'podcast' => $this->podcast,
'podcast' => $this->podcast, 'posts' => (new PostModel())->getActorPublishedPosts($this->podcast->actor_id),
'posts' => (new PostModel())->getActorPublishedPosts($this->podcast->actor_id),
]; ];
// if user is logged in then send to the authenticated activity view // if user is logged in then send to the authenticated activity view
...@@ -96,9 +93,7 @@ class PodcastController extends BaseController ...@@ -96,9 +93,7 @@ class PodcastController extends BaseController
); );
return view('podcast/activity', $data, [ return view('podcast/activity', $data, [
'cache' => $secondsToNextUnpublishedEpisode 'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
? $secondsToNextUnpublishedEpisode
: DECADE,
'cache_name' => $cacheName, 'cache_name' => $cacheName,
]); ]);
} }
...@@ -108,10 +103,7 @@ class PodcastController extends BaseController ...@@ -108,10 +103,7 @@ class PodcastController extends BaseController
public function about(): string public function about(): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->podcast->id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->podcast->id);
}
$cacheName = implode( $cacheName = implode(
'_', '_',
...@@ -130,10 +122,10 @@ class PodcastController extends BaseController ...@@ -130,10 +122,10 @@ class PodcastController extends BaseController
if (! ($cachedView = cache($cacheName))) { if (! ($cachedView = cache($cacheName))) {
$stats = (new EpisodeModel())->getPodcastStats($this->podcast->id); $stats = (new EpisodeModel())->getPodcastStats($this->podcast->id);
set_podcast_metatags($this->podcast, 'about');
$data = [ $data = [
'metatags' => get_podcast_metatags($this->podcast, 'about'), 'podcast' => $this->podcast,
'podcast' => $this->podcast, 'stats' => $stats,
'stats' => $stats,
]; ];
// // if user is logged in then send to the authenticated activity view // // if user is logged in then send to the authenticated activity view
...@@ -148,9 +140,7 @@ class PodcastController extends BaseController ...@@ -148,9 +140,7 @@ class PodcastController extends BaseController
); );
return view('podcast/about', $data, [ return view('podcast/about', $data, [
'cache' => $secondsToNextUnpublishedEpisode 'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
? $secondsToNextUnpublishedEpisode
: DECADE,
'cache_name' => $cacheName, 'cache_name' => $cacheName,
]); ]);
} }
...@@ -160,10 +150,7 @@ class PodcastController extends BaseController ...@@ -160,10 +150,7 @@ class PodcastController extends BaseController
public function episodes(): string public function episodes(): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->podcast->id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->podcast->id);
}
$yearQuery = $this->request->getGet('year'); $yearQuery = $this->request->getGet('year');
$seasonQuery = $this->request->getGet('season'); $seasonQuery = $this->request->getGet('season');
...@@ -249,8 +236,8 @@ class PodcastController extends BaseController ...@@ -249,8 +236,8 @@ class PodcastController extends BaseController
]; ];
} }
set_podcast_metatags($this->podcast, 'episodes');
$data = [ $data = [
'metatags' => get_podcast_metatags($this->podcast, 'episodes'),
'podcast' => $this->podcast, 'podcast' => $this->podcast,
'episodesNav' => $episodesNavigation, 'episodesNav' => $episodesNavigation,
'activeQuery' => $activeQuery, 'activeQuery' => $activeQuery,
...@@ -270,9 +257,7 @@ class PodcastController extends BaseController ...@@ -270,9 +257,7 @@ class PodcastController extends BaseController
$this->podcast->id, $this->podcast->id,
); );
return view('podcast/episodes', $data, [ return view('podcast/episodes', $data, [
'cache' => $secondsToNextUnpublishedEpisode 'cache' => $secondsToNextUnpublishedEpisode ?: DECADE,
? $secondsToNextUnpublishedEpisode
: DECADE,
'cache_name' => $cacheName, 'cache_name' => $cacheName,
]); ]);
} }
...@@ -280,15 +265,15 @@ class PodcastController extends BaseController ...@@ -280,15 +265,15 @@ class PodcastController extends BaseController
return $cachedView; return $cachedView;
} }
public function episodeCollection(): Response public function episodeCollection(): ResponseInterface
{ {
if ($this->podcast->type === 'serial') { if ($this->podcast->type === 'serial') {
// podcast is serial // podcast is serial
$episodes = model(EpisodeModel::class) $episodes = model('EpisodeModel')
->where('`published_at` <= UTC_TIMESTAMP()', null, false) ->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->orderBy('season_number DESC, number ASC'); ->orderBy('season_number DESC, number ASC');
} else { } else {
$episodes = model(EpisodeModel::class) $episodes = model('EpisodeModel')
->where('`published_at` <= UTC_TIMESTAMP()', null, false) ->where('`published_at` <= UTC_TIMESTAMP()', null, false)
->orderBy('published_at', 'DESC'); ->orderBy('published_at', 'DESC');
} }
...@@ -321,9 +306,9 @@ class PodcastController extends BaseController ...@@ -321,9 +306,9 @@ class PodcastController extends BaseController
public function links(): string public function links(): string
{ {
set_podcast_metatags($this->podcast, 'links');
return view('podcast/links', [ return view('podcast/links', [
'metatags' => get_podcast_metatags($this->podcast, 'links'), 'podcast' => $this->podcast,
'podcast' => $this->podcast,
]); ]);
} }
} }
...@@ -22,6 +22,7 @@ use CodeIgniter\HTTP\URI; ...@@ -22,6 +22,7 @@ use CodeIgniter\HTTP\URI;
use CodeIgniter\I18n\Time; use CodeIgniter\I18n\Time;
use Modules\Analytics\AnalyticsTrait; use Modules\Analytics\AnalyticsTrait;
use Modules\Fediverse\Controllers\PostController as FediversePostController; use Modules\Fediverse\Controllers\PostController as FediversePostController;
use Override;
class PostController extends FediversePostController class PostController extends FediversePostController
{ {
...@@ -37,12 +38,14 @@ class PostController extends FediversePostController ...@@ -37,12 +38,14 @@ class PostController extends FediversePostController
protected $post; protected $post;
/** /**
* @var string[] * @var list<string>
*/ */
protected $helpers = ['auth', 'fediverse', 'svg', 'components', 'misc', 'seo', 'premium_podcasts']; protected $helpers = ['auth', 'fediverse', 'svg', 'components', 'misc', 'seo', 'premium_podcasts'];
#[Override]
public function _remap(string $method, string ...$params): mixed public function _remap(string $method, string ...$params): mixed
{ {
if ( if (
! ($podcast = (new PodcastModel())->getPodcastByHandle($params[0])) instanceof Podcast ! ($podcast = (new PodcastModel())->getPodcastByHandle($params[0])) instanceof Podcast
) { ) {
...@@ -52,29 +55,29 @@ class PostController extends FediversePostController ...@@ -52,29 +55,29 @@ class PostController extends FediversePostController
$this->podcast = $podcast; $this->podcast = $podcast;
$this->actor = $this->podcast->actor; $this->actor = $this->podcast->actor;
if (count($params) <= 1) {
unset($params[0]);
return $this->{$method}(...$params);
}
if ( if (
count($params) > 1 && ! ($post = (new PostModel())->getPostById($params[1])) instanceof CastopodPost
($post = (new PostModel())->getPostById($params[1])) instanceof CastopodPost
) { ) {
$this->post = $post; throw PageNotFoundException::forPageNotFound();
unset($params[0]);
unset($params[1]);
} }
$this->post = $post;
unset($params[0]);
unset($params[1]);
return $this->{$method}(...$params); return $this->{$method}(...$params);
} }
public function view(): string public function view(): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->podcast->id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->podcast->id);
}
if (! $this->post instanceof CastopodPost) {
throw PageNotFoundException::forPageNotFound();
}
$cacheName = implode( $cacheName = implode(
'_', '_',
...@@ -89,10 +92,10 @@ class PostController extends FediversePostController ...@@ -89,10 +92,10 @@ class PostController extends FediversePostController
); );
if (! ($cachedView = cache($cacheName))) { if (! ($cachedView = cache($cacheName))) {
set_post_metatags($this->post);
$data = [ $data = [
'metatags' => get_post_metatags($this->post), 'post' => $this->post,
'post' => $this->post, 'podcast' => $this->podcast,
'podcast' => $this->podcast,
]; ];
// if user is logged in then send to the authenticated activity view // if user is logged in then send to the authenticated activity view
...@@ -110,7 +113,8 @@ class PostController extends FediversePostController ...@@ -110,7 +113,8 @@ class PostController extends FediversePostController
return $cachedView; return $cachedView;
} }
public function attemptCreate(): RedirectResponse #[Override]
public function createAction(): RedirectResponse
{ {
$rules = [ $rules = [
'message' => 'required|max_length[500]', 'message' => 'required|max_length[500]',
...@@ -161,7 +165,8 @@ class PostController extends FediversePostController ...@@ -161,7 +165,8 @@ class PostController extends FediversePostController
return redirect()->back(); return redirect()->back();
} }
public function attemptReply(): RedirectResponse #[Override]
public function replyAction(): RedirectResponse
{ {
$rules = [ $rules = [
'message' => 'required|max_length[500]', 'message' => 'required|max_length[500]',
...@@ -200,21 +205,23 @@ class PostController extends FediversePostController ...@@ -200,21 +205,23 @@ class PostController extends FediversePostController
return redirect()->back(); return redirect()->back();
} }
public function attemptFavourite(): RedirectResponse #[Override]
public function favouriteAction(): RedirectResponse
{ {
model('FavouriteModel')->toggleFavourite(interact_as_actor(), $this->post); model('FavouriteModel')->toggleFavourite(interact_as_actor(), $this->post);
return redirect()->back(); return redirect()->back();
} }
public function attemptReblog(): RedirectResponse #[Override]
public function reblogAction(): RedirectResponse
{ {
(new PostModel())->toggleReblog(interact_as_actor(), $this->post); (new PostModel())->toggleReblog(interact_as_actor(), $this->post);
return redirect()->back(); return redirect()->back();
} }
public function attemptAction(): RedirectResponse public function action(): RedirectResponse
{ {
$rules = [ $rules = [
'action' => 'required|in_list[favourite,reblog,reply]', 'action' => 'required|in_list[favourite,reblog,reply]',
...@@ -231,9 +238,9 @@ class PostController extends FediversePostController ...@@ -231,9 +238,9 @@ class PostController extends FediversePostController
$action = $validData['action']; $action = $validData['action'];
return match ($action) { return match ($action) {
'favourite' => $this->attemptFavourite(), 'favourite' => $this->favouriteAction(),
'reblog' => $this->attemptReblog(), 'reblog' => $this->reblogAction(),
'reply' => $this->attemptReply(), 'reply' => $this->replyAction(),
default => redirect() default => redirect()
->back() ->back()
->withInput() ->withInput()
...@@ -241,19 +248,16 @@ class PostController extends FediversePostController ...@@ -241,19 +248,16 @@ class PostController extends FediversePostController
}; };
} }
public function remoteAction(string $action): string public function remoteActionView(string $action): string
{ {
// Prevent analytics hit when authenticated $this->registerPodcastWebpageHit($this->podcast->id);
if (! auth()->loggedIn()) {
$this->registerPodcastWebpageHit($this->podcast->id);
}
set_remote_actions_metatags($this->post, $action);
$data = [ $data = [
'metatags' => get_remote_actions_metatags($this->post, $action), 'podcast' => $this->podcast,
'podcast' => $this->podcast, 'actor' => $this->actor,
'actor' => $this->actor, 'post' => $this->post,
'post' => $this->post, 'action' => $action,
'action' => $action,
]; ];
helper('form'); helper('form');
......
...@@ -21,7 +21,7 @@ class WebmanifestController extends Controller ...@@ -21,7 +21,7 @@ class WebmanifestController extends Controller
/** /**
* @var array<string, array<string, string>> * @var array<string, array<string, string>>
*/ */
final public const THEME_COLORS = [ final public const array THEME_COLORS = [
'pine' => [ 'pine' => [
'theme' => '#009486', 'theme' => '#009486',
'background' => '#F0F9F8', 'background' => '#F0F9F8',
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddCategories extends BaseMigration class AddCategories extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -45,6 +48,7 @@ class AddCategories extends BaseMigration ...@@ -45,6 +48,7 @@ class AddCategories extends BaseMigration
$this->forge->createTable('categories'); $this->forge->createTable('categories');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('categories'); $this->forge->dropTable('categories');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddLanguages extends BaseMigration class AddLanguages extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -31,6 +34,7 @@ class AddLanguages extends BaseMigration ...@@ -31,6 +34,7 @@ class AddLanguages extends BaseMigration
$this->forge->createTable('languages'); $this->forge->createTable('languages');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('languages'); $this->forge->dropTable('languages');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddPodcasts extends BaseMigration class AddPodcasts extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -205,6 +208,7 @@ class AddPodcasts extends BaseMigration ...@@ -205,6 +208,7 @@ class AddPodcasts extends BaseMigration
$this->forge->createTable('podcasts'); $this->forge->createTable('podcasts');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('podcasts'); $this->forge->dropTable('podcasts');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddEpisodes extends BaseMigration class AddEpisodes extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -171,6 +174,7 @@ class AddEpisodes extends BaseMigration ...@@ -171,6 +174,7 @@ class AddEpisodes extends BaseMigration
$this->db->query($createQuery); $this->db->query($createQuery);
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('episodes'); $this->forge->dropTable('episodes');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddPlatforms extends BaseMigration class AddPlatforms extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -41,12 +44,13 @@ class AddPlatforms extends BaseMigration ...@@ -41,12 +44,13 @@ class AddPlatforms extends BaseMigration
]); ]);
$this->forge->addField('`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP()'); $this->forge->addField('`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP()');
$this->forge->addField( $this->forge->addField(
'`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP()' '`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP() ON UPDATE CURRENT_TIMESTAMP()',
); );
$this->forge->addPrimaryKey('slug'); $this->forge->addPrimaryKey('slug');
$this->forge->createTable('platforms'); $this->forge->createTable('platforms');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('platforms'); $this->forge->dropTable('platforms');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddPodcastsPlatforms extends BaseMigration class AddPodcastsPlatforms extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -52,6 +55,7 @@ class AddPodcastsPlatforms extends BaseMigration ...@@ -52,6 +55,7 @@ class AddPodcastsPlatforms extends BaseMigration
$this->forge->createTable('podcasts_platforms'); $this->forge->createTable('podcasts_platforms');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('podcasts_platforms'); $this->forge->dropTable('podcasts_platforms');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddEpisodeComments extends BaseMigration class AddEpisodeComments extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -71,6 +74,7 @@ class AddEpisodeComments extends BaseMigration ...@@ -71,6 +74,7 @@ class AddEpisodeComments extends BaseMigration
$this->forge->createTable('episode_comments'); $this->forge->createTable('episode_comments');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('episode_comments'); $this->forge->dropTable('episode_comments');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddLikes extends BaseMigration class AddLikes extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -34,6 +37,7 @@ class AddLikes extends BaseMigration ...@@ -34,6 +37,7 @@ class AddLikes extends BaseMigration
$this->forge->createTable('likes'); $this->forge->createTable('likes');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('likes'); $this->forge->dropTable('likes');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddPages extends BaseMigration class AddPages extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -48,6 +51,7 @@ class AddPages extends BaseMigration ...@@ -48,6 +51,7 @@ class AddPages extends BaseMigration
$this->forge->createTable('pages'); $this->forge->createTable('pages');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('pages'); $this->forge->dropTable('pages');
......
...@@ -12,8 +12,11 @@ declare(strict_types=1); ...@@ -12,8 +12,11 @@ declare(strict_types=1);
namespace App\Database\Migrations; namespace App\Database\Migrations;
use Override;
class AddPodcastsCategories extends BaseMigration class AddPodcastsCategories extends BaseMigration
{ {
#[Override]
public function up(): void public function up(): void
{ {
$this->forge->addField([ $this->forge->addField([
...@@ -32,6 +35,7 @@ class AddPodcastsCategories extends BaseMigration ...@@ -32,6 +35,7 @@ class AddPodcastsCategories extends BaseMigration
$this->forge->createTable('podcasts_categories'); $this->forge->createTable('podcasts_categories');
} }
#[Override]
public function down(): void public function down(): void
{ {
$this->forge->dropTable('podcasts_categories'); $this->forge->dropTable('podcasts_categories');
......