Update apiv2 app version check to include OS #746
This commit is contained in:
parent
e212e2d29a
commit
f3992f05fc
2 changed files with 15 additions and 9 deletions
|
|
@ -13,6 +13,8 @@ parameters:
|
||||||
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
||||||
country_code: "%env(COUNTRY_CODE)%"
|
country_code: "%env(COUNTRY_CODE)%"
|
||||||
api_version: "%env(API_VERSION)%"
|
api_version: "%env(API_VERSION)%"
|
||||||
|
android_app_version: "%env(ANDROID_APP_VERSION)%"
|
||||||
|
ios_app_version: "%env(IOS_APP_VERSION)%"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ class AppController extends ApiController
|
||||||
// validate params
|
// validate params
|
||||||
$missing = $this->hasMissingParams($req, [
|
$missing = $this->hasMissingParams($req, [
|
||||||
'version',
|
'version',
|
||||||
|
'os',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($missing) {
|
if ($missing) {
|
||||||
|
|
@ -21,21 +22,23 @@ class AppController extends ApiController
|
||||||
$need_update = false;
|
$need_update = false;
|
||||||
$msg = 'Version is up to date.';
|
$msg = 'Version is up to date.';
|
||||||
|
|
||||||
$api_version = $this->getParameter('api_version');
|
|
||||||
|
|
||||||
$app_version = $req->query->get('version');
|
|
||||||
// putting this in for the future, in case we have diverging versions
|
|
||||||
$os = $req->query->get('os');
|
$os = $req->query->get('os');
|
||||||
$platform = $req->query->get('platform');
|
|
||||||
|
|
||||||
$api_v = explode('.', $api_version);
|
// putting this in for the future, in case we have diverging versions
|
||||||
$app_v = explode('.', $app_version);
|
//$platform = $req->query->get('platform');
|
||||||
|
|
||||||
if ($api_v[0] < $app_v[0]) {
|
// get only the major version numbers
|
||||||
|
$app_version = $req->query->get('version');
|
||||||
|
$app_major = substr($app_version, 0, strripos($app_version, "."));
|
||||||
|
|
||||||
|
$latest_version = $this->getParameter($os . '_app_version');
|
||||||
|
$latest_major = substr($latest_version, 0, strripos($latest_version, "."));
|
||||||
|
|
||||||
|
if ($latest_major < $app_major) {
|
||||||
return new ApiResponse(false, 'Invalid application version: ' . $app_version);
|
return new ApiResponse(false, 'Invalid application version: ' . $app_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($api_v[0] > $app_v[0]) {
|
if ($latest_major > $app_major) {
|
||||||
$need_update = true;
|
$need_update = true;
|
||||||
$msg = 'Your version is outdated and needs an update to use the latest features RES-Q has to offer.';
|
$msg = 'Your version is outdated and needs an update to use the latest features RES-Q has to offer.';
|
||||||
}
|
}
|
||||||
|
|
@ -43,6 +46,7 @@ class AppController extends ApiController
|
||||||
// response
|
// response
|
||||||
return new ApiResponse(true, '', [
|
return new ApiResponse(true, '', [
|
||||||
'need_update' => $need_update,
|
'need_update' => $need_update,
|
||||||
|
'latest_version' => $latest_version,
|
||||||
'message' => $msg,
|
'message' => $msg,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue