Move dashboard version check into version api endpoint

This commit is contained in:
James Brooks
2016-06-10 17:27:21 +01:00
parent 1425c15ee8
commit 947aa27e40
5 changed files with 21 additions and 22 deletions
+13 -1
View File
@@ -11,6 +11,13 @@
namespace CachetHQ\Cachet\Http\Controllers\Api;
use CachetHQ\Cachet\Integrations\Releases;
/**
* This is the general api controller.
*
* @author James Brooks <james@bluebaytravel.co.uk>
*/
class GeneralController extends AbstractApiController
{
/**
@@ -30,6 +37,11 @@ class GeneralController extends AbstractApiController
*/
public function version()
{
return $this->item(CACHET_VERSION);
$latest = app(Releases::class)->latest();
return $this->setMetaData([
'on_latest' => version_compare(CACHET_VERSION, $latest['tag_name']) === 1,
'latest' => $latest,
])->item(CACHET_VERSION);
}
}
@@ -91,20 +91,4 @@ class ApiController extends Controller
throw new ModelNotFoundException("Incident template for $templateSlug could not be found.");
}
/**
* Checks if Cachet is up to date.
*
* @return \Illuminate\Http\JsonResponse
*/
public function checkVersion()
{
$latest = app(Releases::class)->latest();
return Response::json([
'cachet_version' => CACHET_VERSION,
'latest_version' => $latest,
'is_latest' => version_compare(CACHET_VERSION, $latest) === 1,
]);
}
}