mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-07 16:56:43 +02:00
feat(rss): add option for 301 redirect to new feed url
This commit is contained in:
parent
696250f041
commit
3a7d26fdf9
4 changed files with 27 additions and 2 deletions
|
|
@ -33,14 +33,25 @@ class FeedController extends Controller
|
|||
|
||||
public function index(string $podcastHandle): ResponseInterface
|
||||
{
|
||||
helper(['rss', 'premium_podcasts', 'misc']);
|
||||
|
||||
$podcast = (new PodcastModel())->where('handle', $podcastHandle)
|
||||
->first();
|
||||
if (! $podcast instanceof Podcast) {
|
||||
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;
|
||||
try {
|
||||
$service = UserAgentsRSS::find(service('superglobals')->server('HTTP_USER_AGENT'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue