...
 
Commits (2)
......@@ -100,21 +100,10 @@ class ShowController extends Controller
abort(404);
}
$feed = Feed::where('id', $feed_id)->first();
if (!$feed) {
$feed = Feed::make(['id' => $feed_id]);
try {
$refresh->refresh($feed);
} catch (RequestException | ConnectException $ex) {
Log::notice("Refresh issue: " . $ex->getMessage());
return response("We had an issue reaching Stitcher.", 503);
}
}
$feed = $this->findOrMake($feed_id, $refresh);
if (!$feed->is_premium && $feed->premium_id) {
$feed = Feed::where('id', $feed->premium_id)->first();
$feed = $this->findOrMake($feed->premium_id, $refresh);
}
if (!$feed->is_premium) {
......@@ -140,6 +129,24 @@ class ShowController extends Controller
);
}
protected function findOrMake(int $feed_id, RefreshShow $refresh): Feed
{
$feed = Feed::where('id', $feed_id)->first();
if (!$feed) {
$feed = Feed::make(['id' => $feed_id]);
try {
$refresh->refresh($feed);
} catch (RequestException | ConnectException $ex) {
Log::notice("Refresh issue: " . $ex->getMessage());
return response("We had an issue reaching Stitcher.", 503);
}
}
return $feed;
}
protected function isCachedByClient(Request $request, string $date): bool
{
$if_modified_since = $request->header('IF_MODIFIED_SINCE', null);
......
......@@ -63,12 +63,14 @@ class User extends Model
$sub_expiration = (string)$xml['subscriptionExpiration'];
if ($sub_state != 3 || !$sub_expiration) {
$this->touch();
return false;
}
$expiration = new \DateTime($sub_expiration);
if ($expiration == $this->expiration) {
$this->touch();
return ($this->expiration >= new \DateTime());
}
......