Fixed the integrations

This commit is contained in:
Graham Campbell
2016-06-03 17:07:36 +01:00
parent 3e8801d8d4
commit abf83361e8
4 changed files with 41 additions and 11 deletions

View File

@@ -29,6 +29,13 @@ class Feed
*/
const URL = 'https://blog.alt-three.com/tag/cachet/rss';
/**
* The failed status indicator.
*
* @var int
*/
const FAILED = 1;
/**
* The cache repository instance.
*
@@ -58,13 +65,13 @@ class Feed
}
/**
* Returns the entries.
* Returns the latest entries.
*
* @return array
* @return array|null
*/
public function entries()
public function latest()
{
return $this->cache->remember('feeds', 720, function () {
$result = $this->cache->remember('feeds', 720, function () {
try {
$xml = simplexml_load_string((new Client())->get($this->url, [
'headers' => ['Accept' => 'application/rss+xml', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'],
@@ -72,8 +79,10 @@ class Feed
return json_decode(json_encode($xml));
} catch (Exception $e) {
// Do nothing, this isn't critical.
return self::FAILED;
}
});
return $result === self::FAILED ? null : $result;
}
}