Commit 66d98eee authored by John Long's avatar John Long

Feed: Add support for serving premium feeds against their free feed IDs

Ideally, we wouldn't do this. However, there are existing users that rely on
these IDs.

Ticket: N/A
parent 6ce662c5
Pipeline #63254490 failed with stages
in 52 seconds
......@@ -77,6 +77,14 @@ class RefreshShow
protected function processFeed(Feed $feed, \SimpleXMLElement $response)
{
if ((int)$response['id'] != $feed->id) {
$premium_id = $response['id'];
} else {
$premium_id = null;
}
$feed->premium_id = $premium_id;
$feed->title = (string)$response->name;
$feed->description = (string)$response->description;
$feed->image_url = (string)$response['imageURL'];
......
......@@ -18,6 +18,7 @@ class Feed extends Model
'title',
'description',
'image_url',
'premium_id',
];
/**
......
......@@ -113,6 +113,10 @@ class ShowController extends Controller
}
}
if (!$feed->is_premium && $feed->premium_id) {
$feed = Feed::where('id', $feed->premium_id)->first();
}
if (!$feed->is_premium) {
return response("Show is not premium. Please fetch from the original provider.", 404);
}
......
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class FeedPremiumMapping extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('feeds', function (Blueprint $table) {
$table->unsignedInteger('premium_id')->nullable(true)->default(null);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('feeds', function (Blueprint $table) {
$table->dropColumn('premium_id');
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment