other: add describe API
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/653/head
parent
4513b461d9
commit
d6c464f09f
|
@ -86,6 +86,7 @@ return [
|
||||||
// Config
|
// Config
|
||||||
['name' => 'Other#setUserConfig', 'url' => '/api/config/{key}', 'verb' => 'PUT'],
|
['name' => 'Other#setUserConfig', 'url' => '/api/config/{key}', 'verb' => 'PUT'],
|
||||||
['name' => 'Other#getUserConfig', 'url' => '/api/config', 'verb' => 'GET'],
|
['name' => 'Other#getUserConfig', 'url' => '/api/config', 'verb' => 'GET'],
|
||||||
|
['name' => 'Other#describeApi', 'url' => '/api/describe', 'verb' => 'GET'],
|
||||||
|
|
||||||
// Admin
|
// Admin
|
||||||
['name' => 'Admin#getSystemStatus', 'url' => '/api/system-status', 'verb' => 'GET'],
|
['name' => 'Admin#getSystemStatus', 'url' => '/api/system-status', 'verb' => 'GET'],
|
||||||
|
|
|
@ -27,7 +27,7 @@ use OCA\Memories\AppInfo\Application;
|
||||||
use OCA\Memories\Db\FsManager;
|
use OCA\Memories\Db\FsManager;
|
||||||
use OCA\Memories\Db\TimelineQuery;
|
use OCA\Memories\Db\TimelineQuery;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\ApiController;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
@ -35,7 +35,7 @@ use OCP\IRequest;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
abstract class GenericApiController extends Controller
|
abstract class GenericApiController extends ApiController
|
||||||
{
|
{
|
||||||
protected IConfig $config;
|
protected IConfig $config;
|
||||||
protected IUserSession $userSession;
|
protected IUserSession $userSession;
|
||||||
|
|
|
@ -98,6 +98,31 @@ class OtherController extends GenericApiController
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
*
|
||||||
|
* @PublicPage
|
||||||
|
*
|
||||||
|
* @NoCSRFRequired
|
||||||
|
*/
|
||||||
|
public function describeApi(): JSONResponse
|
||||||
|
{
|
||||||
|
return Util::guardEx(function () {
|
||||||
|
$appManager = \OC::$server->get(\OCP\App\IAppManager::class);
|
||||||
|
$urlGenerator = \OC::$server->get(\OCP\IURLGenerator::class);
|
||||||
|
|
||||||
|
$res = new JSONResponse([
|
||||||
|
'version' => $appManager->getAppInfo('memories')['version'],
|
||||||
|
'baseUrl' => $urlGenerator->linkToRouteAbsolute('memories.Page.main'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// This is public information
|
||||||
|
$res->addHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue