diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 958aa49..31c6444 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -1,252 +1,252 @@ . * */ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { /** * @var Zend_Controller_Router_Rewrite */ protected $_router = false; /** * @throws Zend_Exception * @throws Zend_Session_Exception */ protected function _initSessionManagement() { - $session = $this->bootstrap('session'); - $domain = Local_Tools_ParseDomain::get_domain(); - Zend_Session::setOptions(array('cookie_domain' => $domain)); - Zend_Session::start(); +// $session = $this->bootstrap('session'); +// $domain = Local_Tools_ParseDomain::get_domain(); +// Zend_Session::setOptions(array('cookie_domain' => $domain)); +// Zend_Session::start(); Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_NonPersistent()); } /** * @return mixed */ protected function _initConfig() { /** $config Zend_Config */ $config = $this->getApplication()->getApplicationConfig(); Zend_Registry::set('config', $config); return $config; } /** * @throws Zend_Application_Bootstrap_Exception */ protected function _initLogger() { /** @var Zend_Log $logger */ $logger = $this->getPluginResource('log')->getLog(); $logger->registerErrorHandler(); Zend_Registry::set('logger', $logger); } /** * @return mixed|null|Zend_Cache_Core|Zend_Cache_Frontend * @throws Zend_Cache_Exception * @throws Zend_Exception */ protected function _initCache() { if (Zend_Registry::isRegistered('cache')) { return Zend_Registry::get('cache'); } $cache = null; $options = $this->getOption('settings'); if (true == $options['cache']['enabled']) { $cache = Zend_Cache::factory( $options['cache']['frontend']['type'], $options['cache']['backend']['type'], $options['cache']['frontend']['options'], $options['cache']['backend']['options'] ); } else { // Fallback settings for some (maybe development) environments which have no cache management installed. if (false === is_writeable(APPLICATION_CACHE)) { error_log('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); exit('directory for cache files does not exists or not writable: ' . APPLICATION_CACHE); } $frontendOptions = array( 'lifetime' => 600, 'automatic_serialization' => true, 'cache_id_prefix' => 'front_cache', 'cache' => true ); $backendOptions = array( 'cache_dir' => APPLICATION_CACHE, 'file_locking' => true, 'read_control' => true, 'read_control_type' => 'crc32', 'hashed_directory_level' => 1, 'hashed_directory_perm' => 0700, 'file_name_prefix' => 'ocs', 'cache_file_perm' => 0700 ); $cache = Zend_Cache::factory( 'Core', 'File', $frontendOptions, $backendOptions ); } Zend_Registry::set('cache', $cache); Zend_Locale::setCache($cache); Zend_Locale_Data::setCache($cache); Zend_Currency::setCache($cache); Zend_Translate::setCache($cache); Zend_Translate_Adapter::setCache($cache); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); Zend_Paginator::setCache($cache); return $cache; } /** * @throws Zend_Application_Bootstrap_Exception * @throws Zend_Exception */ protected function _initDbAdapter() { $db = $this->bootstrap('db')->getResource('db'); if ((APPLICATION_ENV == 'development')) { $profiler = new Zend_Db_Profiler_Firebug('All DB Queries'); $profiler->setEnabled(true); // Attach the profiler to your db adapter $db->setProfiler($profiler); } Zend_Registry::set('db', $db); Zend_Db_Table::setDefaultAdapter($db); Zend_Db_Table_Abstract::setDefaultAdapter($db); $config = Zend_Registry::get('config'); //$db2 = $this->bootstrap('db')->getResource('db2'); try { $db2 = Zend_Db::factory($config->settings->db2->adapter, array( 'host' => $config->settings->db2->params->host, 'username' => $config->settings->db2->params->username, 'password' => $config->settings->db2->params->password, 'dbname' => $config->settings->db2->params->dbname, 'charset' => $config->settings->db2->params->charset, 'type' => $config->settings->db2->params->type, 'persistent' => $config->settings->db2->params->persistent, 'isDefaultTableAdapter' => FALSE )); Zend_Registry::set('db2', $db2); $db2->getConnection(); } catch (Zend_Db_Adapter_Exception $e) { Zend_Registry::get('logger')->err('Error Init DB2: '. $e->getTraceAsString()); //$e->getMessage(); } catch (Zend_Exception $e) { Zend_Registry::get('logger')->err('Error Init DB2: '. $e->getTraceAsString()); //$e->getMessage(); } } protected function _initRouter() { /** @var Zend_Cache_Core $cache */ $cache = Zend_Registry::get('cache'); $this->_router = $cache->load('ocs_api_router'); $bootstrap = $this; $bootstrap->bootstrap('FrontController'); if (false === $this->_router) { $this->_router = $bootstrap->getContainer()->frontcontroller->getRouter(); $options = $this->getOptions()['resources']['router']; if (!isset($options['routes'])) { $options['routes'] = array(); } if (isset($options['chainNameSeparator'])) { $this->_router->setChainNameSeparator($options['chainNameSeparator']); } if (isset($options['useRequestParametersAsGlobal'])) { $this->_router->useRequestParametersAsGlobal($options['useRequestParametersAsGlobal']); } $this->_router->addConfig(new Zend_Config($options['routes'])); $cache->save($this->_router, 'ocs_api_router', array(), 7200); } $this->getContainer()->frontcontroller->setRouter($this->_router); return $this->_router; } protected function _initGlobalAppConst() { $appConfig = $this->getResource('config'); $imageConfig = $appConfig->images; defined('IMAGES_UPLOAD_PATH') || define('IMAGES_UPLOAD_PATH', $imageConfig->upload->path); defined('IMAGES_MEDIA_SERVER') || define('IMAGES_MEDIA_SERVER', $imageConfig->media->server); // ppload $configFileserver = $appConfig->settings->server->files; defined('PPLOAD_API_URI') || define('PPLOAD_API_URI', $configFileserver->api->uri); defined('PPLOAD_CLIENT_ID') || define('PPLOAD_CLIENT_ID', $configFileserver->api->client_id); defined('PPLOAD_SECRET') || define('PPLOAD_SECRET', $configFileserver->api->client_secret); defined('PPLOAD_HOST') || define('PPLOAD_HOST', $configFileserver->host); defined('PPLOAD_DOWNLOAD_SECRET') || define('PPLOAD_DOWNLOAD_SECRET', $configFileserver->download_secret); } protected function _initGlobalApplicationVars() { $modelDomainConfig = new Application_Model_DbTable_ConfigStore(); Zend_Registry::set('application_store_category_list', $modelDomainConfig->fetchAllStoresAndCategories()); Zend_Registry::set('application_store_config_list', $modelDomainConfig->fetchAllStoresConfigArray()); Zend_Registry::set('application_store_config_id_list', $modelDomainConfig->fetchAllStoresConfigByIdArray()); } protected function _initStoreDependentVars() { /** @var $front Zend_Controller_Front */ $front = $this->bootstrap('frontController')->getResource('frontController'); $front->registerPlugin(new Application_Plugin_InitGlobalStoreVars()); } } diff --git a/application/models/PpLoad.php b/application/models/PpLoad.php index bab8442..34e9cc6 100644 --- a/application/models/PpLoad.php +++ b/application/models/PpLoad.php @@ -1,205 +1,206 @@ . * * Created: 26.01.2017 */ class Application_Model_PpLoad { /** * @inheritDoc */ public function __construct() { } public static function createDownloadUrl($collection_id, $file_name, array $params) { $valid_until = time() + 3600; // one hour valid $hash = self::createDownloadHash($collection_id, $valid_until); $url = PPLOAD_API_URI . 'files/download'; foreach ($params as $key => $param) { $url .= '/' . $key . '/' . $param; } return $url . '/s/' . $hash . '/t/' . $valid_until . '/' . $file_name; } /** * @param int $collection_id * @param int $valid_until * @return string */ public static function createDownloadHash($collection_id, $valid_until) { return hash('sha512', PPLOAD_DOWNLOAD_SECRET . $collection_id . $valid_until); // order isn't important at all... just do the same when verifying } /** * @param int $collection_id * @param string $file_name * @param array $payload * @return string + * @throws Zend_Exception */ public static function createDownloadUrlJwt($collection_id, $file_name, array $payload) { $valid_until = time() + 3600; // one hour valid $hash = self::createDownloadHash($collection_id, $valid_until); $payload['s'] = $hash; $payload['t'] = $valid_until; try { - $session = new Zend_Session_Namespace(); - $payload['stfp'] = $session->stat_fp; - $payload['stip'] = $session->stat_ipv6 ? $session->stat_ipv6 : $session->stat_ipv4; + $payload['stfp'] = null; + $requestIp = Zend_Controller_Front::getInstance()->getRequest()->getClientIp(); + $payload['stip'] = $requestIp; } catch (Zend_Session_Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' ' . $e->getMessage()); // error_log(__METHOD__ . ' ' . $e->getMessage()); } $jwt = Application_Model_Jwt::encodeFromArray($payload); return PPLOAD_API_URI . 'files/download/j/' . $jwt . '/' . $file_name; } /** * @param int $projectId * @param string $url * @param string $filename * @param string $fileDescription * @return bool|mixed * @throws Zend_Auth_Storage_Exception * @throws Zend_Exception */ public function uploadEmptyFileWithLink($projectId, $url, $filename, $fileDescription) { $projectId = (int)$projectId; $projectData = $this->getProjectData($projectId); if (empty($projectData)) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ppload upload error. no project data found. project_id:' . $projectId); return false; } $pploadApi = $this->getPpLoadApi(); // create empty text file $fileDummy = '../../data/files/empty'; $fileRequest = array( // 'file' => $fileDummy, 'local_file_path' => $fileDummy, 'local_file_name' => $filename, 'owner_id' => $projectData->member_id, 'tags' => 'link##' . urlencode($url) ); if ($projectData->ppload_collection_id) { // Append to existing collection $fileRequest['collection_id'] = $projectData->ppload_collection_id; } if (false == empty($fileDescription)) { $fileRequest['description'] = mb_substr($fileDescription, 0, 140); } //upload to ppload $fileResponse = $pploadApi->postFile($fileRequest); Zend_Registry::get('logger')->debug(__METHOD__ . ' - fileResponse: ' . print_r($fileResponse, true)); if (empty($fileResponse) OR empty($fileResponse->file) OR $fileResponse->status <> 'success') { Zend_Registry::get('logger')->err(__METHOD__ . ' - ppload upload error. requestData:' . print_r($fileRequest, true) . "\n" . 'response:' . print_r($fileResponse, true) ); return false; } $log = Zend_Registry::get('logger'); if ($projectData->ppload_collection_id <> $fileResponse->file->collection_id) { $projectData->ppload_collection_id = $fileResponse->file->collection_id; if ($this->isAuthmemberProjectCreator($projectData->member_id)) { $projectData->changed_at = new Zend_Db_Expr('NOW()'); } else { $auth = Zend_Auth::getInstance(); $authMember = $auth->getStorage()->read(); $log->info('********** ' . __METHOD__ . ' Project ChangedAt is not set: Auth-Member (' . $authMember->member_id . ') != Project-Owner (' . $projectData->member_id . '): **********' . "\n"); } $projectData->save(); } else { if ($this->isAuthmemberProjectCreator($projectData->member_id)) { $projectData->changed_at = new Zend_Db_Expr('NOW()'); $projectData->save(); } else { $auth = Zend_Auth::getInstance(); $authMember = $auth->getStorage()->read(); $log->info('********** ' . __METHOD__ . ' Project ChangedAt is not set: Auth-Member (' . $authMember->member_id . ') != Project-Owner (' . $projectData->member_id . '): **********' . "\n"); } } return $fileResponse; } /** * @param int $projectId * * @return Zend_Db_Table_Row_Abstract * @throws Zend_Db_Table_Exception */ protected function getProjectData($projectId) { $projectTable = new Default_Model_DbTable_Project(); return $projectTable->find($projectId)->current(); } /** * @return Ppload_Api */ protected function getPpLoadApi() { return new Ppload_Api(array( 'apiUri' => PPLOAD_API_URI, 'clientId' => PPLOAD_CLIENT_ID, 'secret' => PPLOAD_SECRET )); } /** * @param int $creator_id * @return bool * @throws Zend_Auth_Storage_Exception */ public function isAuthmemberProjectCreator($creator_id) { $auth = Zend_Auth::getInstance(); $authMember = $auth->getStorage()->read(); if ($authMember->member_id == $creator_id) { return true; } return false; } } \ No newline at end of file diff --git a/public/swagger/openapi.json b/public/swagger/openapi.json index 3d9a09c..0a953cc 100644 --- a/public/swagger/openapi.json +++ b/public/swagger/openapi.json @@ -1,1406 +1,1406 @@ { "openapi": "3.0.0", "info": { "title": "OCS API", - "description": "Partial implementation of the Open Collaboration Services v1.6 (https://www.freedesktop.org/wiki/Specifications/open-collaboration-services/).", + "description": "Partial implementation of the Open Collaboration Services v1.6 (https://www.freedesktop.org/wiki/Specifications/open-collaboration-services/).\n Important:\n- The HTTP cache in the browser must be switched off, otherwise the same result can always be displayed.\n- Additional privacy tools or similar plugins should be switched off. Otherwise the CORS request may not work.", "version": "0.0.1", "termsOfService": "https://www.opendesktop.org/terms", "contact": { "email": "contect@opendesktop.org" }, "license": { "name": "GNU Affero General Public License", "url": "http://www.gnu.org/licenses/" } }, "servers": [ { "url": "https://api.opendesktop.cc/ocs/v1", "description": "Sandbox server (uses test data)" }, { "url": "https://api.opendesktop.org/ocs/v1", "description": "Production server (uses live data)" } ], "paths": { "/content/categories": { "get": { "description": "Returns a list of available categories", "tags": [ "content" ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/Category" }, "xml": { "name": "data", "wrapped": true } } } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "categories": { "type": "array", "items": { "$ref": "#/components/schemas/Category" }, "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/content/data": { "get": { "description": "Gets a list of a specific set of contents.", "tags": [ "content" ], "security": [ { "BasicAuth": [] }, { "BearerAuth": [] } ], "parameters": [ { "in": "query", "name": "categories", "schema": { "type": "string" }, "description": "Requested category IDs separated by \",\". For backward compatibility with the OCS API specification, the values can also be separated by \"x\"." }, { "in": "query", "name": "search", "schema": { "type": "string" }, "description": "The part of the name of the item you want to find." }, { "in": "query", "name": "tags", "schema": { "type": "string" }, "description": "tags parameter values separated by \",\" and \"|\" for or filter" }, { "in": "query", "name": "xdg_types", "schema": { "type": "string" }, "description": "xdg_types parameter values separated by \",\"" }, { "in": "query", "name": "ghns_excluded", "schema": { "type": "string" } }, { "in": "query", "name": "user", "schema": { "type": "string" }, "description": "show only contents from one specific user." }, { "in": "query", "name": "showfavorites", "schema": { "type": "string" }, "description": "Show only favorites for auhtorized user" }, { "in": "query", "name": "sortmode", "schema": { "type": "string", "enum": [ "new", "alpha", "high", "down" ] } }, { "in": "query", "name": "page", "schema": { "type": "string" }, "description": "The content page. You can control the size of a page with the pagesize argument. The first page is 0, the second is 1, ..." }, { "in": "query", "name": "pagesize", "schema": { "type": "string" }, "description": "The amount of entries per page." } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/ContentCategories" }, "xml": { "name": "data", "wrapped": true } } } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "categories": { "type": "array", "items": { "$ref": "#/components/schemas/ContentCategories" }, "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/content/data/{contentid}": { "get": { "description": "Read content data of one specific content.", "tags": [ "content" ], "parameters": [ { "in": "path", "name": "contentid", "schema": { "type": "integer" }, "required": true } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/ContentDetails" }, "xml": { "name": "data", "wrapped": true } } } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "categories": { "type": "array", "items": { "$ref": "#/components/schemas/ContentDetails" }, "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/content/download/{contentid}/{itemid}": { "get": { "description": "Download or buy one specific content item. links to the package and links to repositories are supported. You get the dowloadlink or the packagename/packagerepository comination in the XML.", "tags": [ "content" ], "parameters": [ { "in": "path", "name": "contentid", "schema": { "type": "integer" }, "required": true }, { "in": "path", "name": "itemid", "schema": { "type": "integer" }, "required": true } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/ContentDownload" }, "xml": { "name": "data", "wrapped": true } } } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "categories": { "type": "array", "items": { "$ref": "#/components/schemas/ContentDownload" }, "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/content/previewpic/{contentid}": { "get": { "description": "tbd", "tags": [ "content" ], "parameters": [ { "in": "path", "name": "contentid", "schema": { "type": "integer" }, "required": true } ], "responses": { "200": { "description": "successful operation" } } } }, "/content/vote/{contentid}": { "get": { "description": "Vote for one specific content.", "tags": [ "content" ], "security": [ { "BasicAuth": [] }, { "BearerAuth": [] } ], "parameters": [ { "in": "path", "name": "contentid", "schema": { "type": "integer" }, "required": true }, { "in": "query", "name": "vote", "schema": { "type": "integer", "minimum": 0, "maximum": 100 }, "required": true }, { "in": "query", "name": "msg", "schema": { "type": "string" } } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/MetaVote" }, "data": { "type": "object", "xml": { "name": "data", "wrapped": true } } } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/MetaVote" }, "data": { "type": "object", "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/person/check": { "post": { "description": "Check if the given login and password or the API key is valid. It returns the associated username.", "tags": [ "person" ], "requestBody": { "required": true, "content": { "application/x-www-form-urlencoded": { "schema": { "type": "object", "properties": { "login": { "type": "string" }, "password": { "type": "string" } }, "required": [ "login", "password" ] } } } }, "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "anyOf": [ { "$ref": "#/components/schemas/Meta" }, { "$ref": "#/components/schemas/PersonId" } ] }, "example": { "status": "ok", "statuscode": "100", "message": "ok", "data": { "details": "check", "personid": "frank" } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/PersonId" }, "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/person/data/{person_id}": { "get": { "description": "Response Get the data from one specific person. Unauthorized request => The response contains only the public part of the personal data. Only authenticated users are allowed to access full data set. Authentication is done by sending a Basic HTTP Authorisation header.", "tags": [ "person" ], "security": [ { "BasicAuth": [] }, { "BearerAuth": [] } ], "parameters": [ { "in": "path", "name": "person_id", "schema": { "type": "string" }, "required": true, "description": "ID of the user to get" } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "anyOf": [ { "$ref": "#/components/schemas/Meta" }, { "$ref": "#/components/schemas/Person" } ] }, "example": { "status": "ok", "statuscode": "100", "message": "ok", "data": { "details": "full", "personid": "dummy", "privacy": 0, "privacytext": "public", "firstname": "dummy_firstname", "lastname": "dummy_lastname", "gender": "", "communityrole": "", "homepage": "www.pling.com", "company": "", "avatarpic": "http://www.pling.com/member/avatar/96515bebd8e2ecbd1cf4625035ddf045/800", "avatarpicfound": 1, "bigavatarpic": "http://www.pling.com/member/avatar/96515bebd8e2ecbd1cf4625035ddf045/800", "bigavatarpicfound": 1, "birthday": "", "jobstatus": "", "city": "Berlin", "country": "Germany", "latitude": "", "longitude": "", "ircnick": "", "ircchannels": "", "irclink": "", "likes": "", "dontlikes": "", "interests": "", "languages": "", "programminglanguages": "", "favouritequote": "", "favouritemusic": "", "favouritetvshows": "", "favouritemovies": "", "favouritebooks": "", "favouritegames": "", "description": "", "profilepage": "http://www.pling.com/u/dummy" } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/Person" }, "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/person/self": { "get": { "description": "get the data from yourself. Only authenticated users are allowed to access this method. Authentication is done by sending a Basic HTTP Authorisation header.", "tags": [ "person" ], "security": [ { "BasicAuth": [] }, { "BearerAuth": [] }, { "OpenID": [] } ], "responses": { "200": { "description": "successful operation", "content": { "application/json": { "schema": { "anyOf": [ { "$ref": "#/components/schemas/Meta" }, { "$ref": "#/components/schemas/Person" } ] }, "example": { "status": "ok", "statuscode": "100", "message": "ok", "data": { "details": "full", "personid": "dummy", "privacy": 0, "privacytext": "public", "firstname": "dummy_firstname", "lastname": "dummy_lastname", "gender": "", "communityrole": "", "homepage": "www.pling.com", "company": "", "avatarpic": "http://www.pling.com/member/avatar/96515bebd8e2ecbd1cf4625035ddf045/800", "avatarpicfound": 1, "bigavatarpic": "http://www.pling.com/member/avatar/96515bebd8e2ecbd1cf4625035ddf045/800", "bigavatarpicfound": 1, "birthday": "", "jobstatus": "", "city": "Berlin", "country": "Germany", "latitude": "", "longitude": "", "ircnick": "", "ircchannels": "", "irclink": "", "likes": "", "dontlikes": "", "interests": "", "languages": "", "programminglanguages": "", "favouritequote": "", "favouritemusic": "", "favouritetvshows": "", "favouritemovies": "", "favouritebooks": "", "favouritegames": "", "description": "", "profilepage": "http://www.pling.com/u/dummy" } } }, "application/xml": { "schema": { "type": "object", "properties": { "meta": { "$ref": "#/components/schemas/Meta" }, "data": { "type": "array", "items": { "$ref": "#/components/schemas/Person" }, "xml": { "name": "data", "wrapped": true } } }, "xml": { "name": "ocs", "wrapped": true } } } } } } } }, "/comments/data/{comment_type}/{contentid}/{second_id}": { "get": { "description": "Gets a list of comments.", "tags": [ "comments" ], "security": [ { "BasicAuth": [] }, { "BearerAuth": [] } ], "parameters": [ { "in": "path", "name": "comment_type", "schema": { "type": "string" }, "required": true }, { "in": "path", "name": "contentid", "schema": { "type": "integer" }, "required": true }, { "in": "path", "name": "second_id", "schema": { "type": "integer" }, "required": true }, { "in": "query", "name": "page", "schema": { "type": "integer" } }, { "in": "query", "name": "pagesize", "schema": { "type": "integer" } } ], "responses": { "200": { "description": "successful operation" } } } } }, "components": { "schemas": { "Meta": { "type": "object", "properties": { "status": { "type": "string" }, "statuscode": { "type": "integer", "format": "int64" }, "message": { "type": "string" }, "totalitems": { "type": "integer", "format": "int64" }, "itemsperpage": { "type": "integer", "format": "int64" } }, "xml": { "name": "meta" } }, "Category": { "type": "object", "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "display-name": { "type": "string" }, "parent_id": { "type": "integer", "format": "int64" }, "xdg_type": { "type": "integer", "format": "int64" } }, "xml": { "name": "category" } }, "ContentCategories": { "type": "object", "properties": { "details": { "type": "string", "xml": { "attribute": true } }, "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "version": { "type": "string" }, "typeid": { "type": "integer" }, "typename": { "type": "string" }, "xdg_type": { "type": "string" }, "language": { "type": "string" }, "personid": { "type": "string" }, "created": { "type": "string" }, "changed": { "type": "string" }, "downloads": { "type": "integer" }, "score": { "type": "integer" }, "summary": { "type": "string" }, "description": { "type": "string" }, "comments": { "type": "integer" }, "ghns_excluded": { "type": "integer" }, "preview1": { "type": "string" }, "detailpage": { "type": "string" }, "tags": { "type": "string" }, "previewpic1": { "type": "string" }, "previewpic2": { "type": "string" }, "smallpreviewpic1": { "type": "string" }, "smalpreviewpic2": { "type": "string" }, "downloadway1": { "type": "integer" }, "downloadtype1": { "type": "string" }, "downloadprice1": { "type": "number" }, "downloadlink1": { "type": "string" }, "downloadname1": { "type": "string" }, "downloadsize1": { "type": "integer" }, "downloadgpgfingerprint1": { "type": "string" }, "downloadgpgsignature1": { "type": "string" }, "downloadpackagename1": { "type": "string" }, "downloadrepository1": { "type": "string" }, "download_package_type1": { "type": "string" }, "download_package_arch1": { "type": "string" }, "downloadtags1": { "type": "string" } }, "xml": { "name": "content" } }, "ContentDetails": { "type": "object", "properties": { "details": { "type": "string", "xml": { "attribute": true } }, "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "version": { "type": "string" }, "typeid": { "type": "integer" }, "typename": { "type": "string" }, "xdg_type": { "type": "string" }, "language": { "type": "string" }, "personid": { "type": "string" }, "created": { "type": "string" }, "changed": { "type": "string" }, "downloads": { "type": "integer" }, "score": { "type": "integer" }, "summary": { "type": "string" }, "description": { "type": "string" }, "changelog": { "type": "string" }, "feedbackurl": { "type": "string" }, "homepage": { "type": "string" }, "homepagetype": { "type": "string" }, "donationpage": { "type": "string" }, "comments": { "type": "integer" }, "commentspage": { "type": "string" }, "fans": { "type": "integer" }, "fanspage": { "type": "string" }, "knowledgebaseentries": { "type": "integer" }, "knowledgebasepage": { "type": "string" }, "depend": { "type": "string" }, "preview1": { "type": "string" }, "icon": { "type": "string" }, "video": { "type": "string" }, "detailpage": { "type": "string" }, "ghns_excluded": { "type": "integer" }, "tags": { "type": "string" }, "previewpic1": { "type": "string" }, "previewpic2": { "type": "string" }, "smallpreviewpic1": { "type": "string" }, "smalpreviewpic2": { "type": "string" }, "downloadway1": { "type": "integer" }, "downloadtype1": { "type": "string" }, "downloadprice1": { "type": "number" }, "downloadlink1": { "type": "string" }, "downloadname1": { "type": "string" }, "downloadsize1": { "type": "integer" }, "downloadgpgfingerprint1": { "type": "string" }, "downloadgpgsignature1": { "type": "string" }, "downloadpackagename1": { "type": "string" }, "downloadrepository1": { "type": "string" }, "download_package_type1": { "type": "string" }, "download_package_arch1": { "type": "string" }, "downloadtags1": { "type": "string" } }, "xml": { "name": "content" } }, "ContentDownload": { "type": "object", "properties": { "details": { "type": "string", "xml": { "attribute": true } }, "downloadway": { "type": "string" }, "downloadlink": { "type": "string" }, "mimetype": { "type": "string" }, "gpgfingerprint": { "type": "string" }, "gpgsignature": { "type": "string" }, "packagename": { "type": "string" }, "repository": { "type": "string" }, "download_package_type": { "type": "string" }, "download_package_arch": { "type": "string" }, "downloadtags": { "type": "string" } }, "xml": { "name": "content" } }, "Person": { "type": "object", "properties": { "details": { "type": "string", "xml": { "attribute": true } }, "personid": { "type": "string" }, "privacy": { "type": "integer", "format": "int64" }, "privacytext": { "type": "string" }, "firstname": { "type": "string" }, "lastname": { "type": "string" }, "gender": { "type": "string" }, "communityrole": { "type": "string" }, "homepage": { "type": "string" }, "company": { "type": "string" }, "avatarpic": { "type": "string" }, "avatarpicfound": { "type": "integer" }, "birthday": { "type": "string" }, "jobstatus": { "type": "string" }, "city": { "type": "string" }, "country": { "type": "string" }, "latitude": { "type": "string" }, "longtitude": { "type": "string" }, "ircnick": { "type": "string" }, "ircchannels": { "type": "string" }, "irclink": { "type": "string" }, "likes": { "type": "integer" }, "dontlikes": { "type": "integer" }, "interests": { "type": "string" }, "languages": { "type": "string" }, "programminglanguages": { "type": "string" }, "favouritequote": { "type": "string" }, "favouritemusic": { "type": "string" }, "favouritetvshows": { "type": "string" }, "favouritemovies": { "type": "string" }, "favouritebooks": { "type": "string" }, "favouritegames": { "type": "string" }, "description": { "type": "string" }, "profilepage": { "type": "string" } }, "xml": { "name": "person" } }, "PersonId": { "type": "object", "properties": { "details": { "type": "string", "xml": { "attribute": true } }, "personid": { "type": "string" } }, "xml": { "name": "person" } }, "MetaVote": { "type": "object", "properties": { "status": { "type": "string" }, "statuscode": { "type": "integer", "format": "int64" }, "message": { "type": "string" }, "score": { "type": "integer", "format": "int64" } }, "xml": { "name": "meta" } } }, "securitySchemes": { "BasicAuth": { "type": "http", "scheme": "basic" }, "BearerAuth": { "type": "http", "scheme": "bearer" } } } } \ No newline at end of file diff --git a/public/swagger/openapi.yaml b/public/swagger/openapi.yaml index e587cd7..d7e2c9c 100644 --- a/public/swagger/openapi.yaml +++ b/public/swagger/openapi.yaml @@ -1,934 +1,937 @@ openapi: "3.0.0" info: title: OCS API - description: Partial implementation of the Open Collaboration Services v1.6 (https://www.freedesktop.org/wiki/Specifications/open-collaboration-services/). + description: "Partial implementation of the Open Collaboration Services v1.6 (https://www.freedesktop.org/wiki/Specifications/open-collaboration-services/). + Important + - The HTTP cache in the browser must be switched off, otherwise the same result can always be displayed. + - Additional privacy tools or similar plugins should be switched off. Otherwise the CORS request may not work." version: 0.0.1 termsOfService: "https://www.opendesktop.org/terms" contact: email: "contect@opendesktop.org" license: name: "GNU Affero General Public License" url: "http://www.gnu.org/licenses/" servers: - url: http://localhost:8070/ocs/v1 description: DEV server - url: https://api.opendesktop.cc/ocs/v1 description: Sandbox server (uses test data) - url: https://api.opendesktop.org/ocs/v1 description: Production server (uses live data) paths: /content/categories: get: description: Returns a list of available categories tags: - content responses: 200: description: "successful operation" content: application/json: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" data: type: "array" items: $ref: "#/components/schemas/Category" xml: name: "data" wrapped: true application/xml: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" categories: type: "array" items: $ref: "#/components/schemas/Category" xml: name: "data" wrapped: true xml: name: "ocs" wrapped: true /content/data: get: description: Gets a list of a specific set of contents. tags: - content security: - BasicAuth: [] - BearerAuth: [] parameters: - in: query name: categories schema: type: string description: Requested category IDs separated by ",". For backward compatibility with the OCS API specification, the values can also be separated by "x". - in: query name: search schema: type: string description: The part of the name of the item you want to find. - in: query name: tags schema: type: string description: tags parameter values separated by "," and "|" for or filter - in: query name: xdg_types schema: type: string description: xdg_types parameter values separated by "," - in: query name: ghns_excluded schema: type: string - in: query name: user schema: type: string description: show only contents from one specific user. - in: query name: showfavorites schema: type: string description: Show only favorites for auhtorized user - in: query name: sortmode schema: type: string enum: [new,alpha,high,down] - in: query name: page schema: type: string description: The content page. You can control the size of a page with the pagesize argument. The first page is 0, the second is 1, ... - in: query name: pagesize schema: type: string description: The amount of entries per page. responses: 200: description: "successful operation" content: application/json: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" data: type: "array" items: $ref: "#/components/schemas/ContentCategories" xml: name: "data" wrapped: true application/xml: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" categories: type: "array" items: $ref: "#/components/schemas/ContentCategories" xml: name: "data" wrapped: true xml: name: "ocs" wrapped: true /content/data/{contentid}: get: description: Read content data of one specific content. tags: - content parameters: - in: path name: contentid schema: type: integer required: true responses: 200: description: "successful operation" content: application/json: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" data: type: "array" items: $ref: "#/components/schemas/ContentDetails" xml: name: "data" wrapped: true application/xml: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" categories: type: "array" items: $ref: "#/components/schemas/ContentDetails" xml: name: "data" wrapped: true xml: name: "ocs" wrapped: true /content/download/{contentid}/{itemid}: get: description: Download or buy one specific content item. links to the package and links to repositories are supported. You get the dowloadlink or the packagename/packagerepository comination in the XML. tags: - content parameters: - in: path name: contentid schema: type: integer required: true - in: path name: itemid schema: type: integer required: true responses: 200: description: "successful operation" content: application/json: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" data: type: "array" items: $ref: "#/components/schemas/ContentDownload" xml: name: "data" wrapped: true application/xml: schema: type: "object" properties: meta: $ref: "#/components/schemas/Meta" categories: type: "array" items: $ref: "#/components/schemas/ContentDownload" xml: name: "data" wrapped: true xml: name: "ocs" wrapped: true /content/previewpic/{contentid}: get: description: tbd tags: - content parameters: - in: path name: contentid schema: type: integer required: true responses: 200: description: "successful operation" /content/vote/{contentid}: get: description: Vote for one specific content. tags: - content security: - BasicAuth: [] - BearerAuth: [] parameters: - in: path name: contentid schema: type: integer required: true - in: query name: vote schema: type: integer minimum: 0 maximum: 100 required: true - in: query name: msg schema: type: string responses: 200: description: "successful operation" content: application/json: schema: type: "object" properties: meta: $ref: "#/components/schemas/MetaVote" data: type: "object" xml: name: "data" wrapped: true application/xml: schema: type: "object" properties: meta: $ref: "#/components/schemas/MetaVote" data: type: "object" xml: name: "data" wrapped: true xml: name: "ocs" wrapped: true /person/check: post: description: Check if the given login and password or the API key is valid. It returns the associated username. tags: - person requestBody: required: true content: application/x-www-form-urlencoded: schema: type: object properties: login: #