Skip to content

Commit c5e4a4f

Browse files
committed
Added version check to API
1 parent 35237e5 commit c5e4a4f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

appinfo/routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
array('name' => 'ownnote_api#index', 'url' => '/api/v0.2/ownnote', 'verb' => 'GET'),
2828
array('name' => 'ownnote_api#remoteindex', 'url' => '/api/v0.2/ownnote/remoteindex', 'verb' => 'GET'),
2929
array('name' => 'ownnote_api#announcement', 'url' => '/api/v0.2/ownnote/announcement', 'verb' => 'GET'),
30+
array('name' => 'ownnote_api#version', 'url' => '/api/v0.2/ownnote/version', 'verb' => 'GET'),
3031
array('name' => 'ownnote_api#ren', 'url' => '/api/v0.2/ownnote/ren', 'verb' => 'POST'),
3132
array('name' => 'ownnote_api#edit', 'url' => '/api/v0.2/ownnote/edit', 'verb' => 'POST'),
3233
array('name' => 'ownnote_api#del', 'url' => '/api/v0.2/ownnote/del', 'verb' => 'POST'),

controller/ownnoteapicontroller.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ public function rengroup() {
159159
return renameGroup($FOLDER, $_POST["group"], $_POST["newgroup"]);
160160
}
161161

162+
/**
163+
* @NoAdminRequired
164+
* @CORS
165+
* @NoCSRFRequired
166+
*/
167+
public function version() {
168+
require_once 'ownnote/lib/backend.php';
169+
return getVersion();
170+
}
171+
162172
/**
163173
* @CORS
164174
* @NoCSRFRequired

lib/backend.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,4 +372,12 @@ function renameGroup($FOLDER, $group, $newgroup) {
372372
return "DONE";
373373
}
374374

375+
function getVersion() {
376+
$v = file_get_contents(__DIR__."/../appinfo/version");
377+
if ($v)
378+
return trim($v);
379+
else
380+
return "";
381+
}
382+
375383
?>

0 commit comments

Comments
 (0)