зеркало из https://github.com/nextcloud/news.git
style fixes
This commit is contained in:
Родитель
60c4dfbd96
Коммит
06367d8b81
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace OCA\News\AppInfo;
|
||||
|
||||
use \OCA\News\Config\DependencyException;
|
||||
|
||||
$container = new Application();
|
||||
|
||||
$config = $container->getAppConfig();
|
||||
|
@ -24,7 +26,7 @@ $config->registerHooks();
|
|||
// check for correct app dependencies
|
||||
try {
|
||||
$config->testDependencies();
|
||||
} catch(\OCA\News\Config\DependencyException $e) {
|
||||
} catch(DependencyException $e) {
|
||||
$logger = $container->getLogger();
|
||||
$params = $container->getLoggerParameters();
|
||||
$logger->emergency($e->getMessage(), $params);
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace OCA\News\AppInfo;
|
|||
|
||||
use \OC\Files\View;
|
||||
use \OCP\AppFramework\App;
|
||||
use \OCP\Util;
|
||||
use \OCP\User;
|
||||
|
||||
use \OCA\News\Config\AppConfig;
|
||||
|
||||
|
@ -260,7 +262,7 @@ class Application extends App {
|
|||
$c->query('L10N'),
|
||||
$c->query('ServerContainer')->getURLGenerator(),
|
||||
phpversion(),
|
||||
implode('.', \OCP\Util::getVersion()),
|
||||
implode('.', Util::getVersion()),
|
||||
$apps,
|
||||
$extensions,
|
||||
$c->query('DatabaseType')
|
||||
|
@ -275,7 +277,7 @@ class Application extends App {
|
|||
});
|
||||
|
||||
$container->registerService('UserId', function() {
|
||||
return \OCP\User::getUser();
|
||||
return User::getUser();
|
||||
});
|
||||
|
||||
$container->registerService('Logger', function($c) {
|
||||
|
|
|
@ -50,9 +50,10 @@ class Enhancer {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
/**
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
private function removeTrailingSlash($url) {
|
||||
if($url[strlen($url)-1] === '/') {
|
||||
return substr($url, 0, -1);
|
||||
|
|
|
@ -21,20 +21,21 @@ use \OCA\News\Utility\Config;
|
|||
class XPathArticleEnhancer implements ArticleEnhancer {
|
||||
|
||||
|
||||
private $feedRegex;
|
||||
private $fileFactory;
|
||||
private $maximumTimeout;
|
||||
private $config;
|
||||
private $regexXPathPair;
|
||||
|
||||
|
||||
/**
|
||||
* @param SimplePieFileFactory a factory for getting a simple pie file instance
|
||||
* @param array $regexXPathPair an associative array containing regex to
|
||||
* match the url and the xpath that should be used for it to extract the
|
||||
* page
|
||||
* @param int $maximumTimeout maximum timeout in seconds, defaults to 10 sec
|
||||
*/
|
||||
/**
|
||||
* @param \OCA\News\Utility\SimplePieAPIFactory $fileFactory
|
||||
* @param array $regexXPathPair an associative array containing regex to
|
||||
* match the url and the xpath that should be used for it to extract the
|
||||
* page
|
||||
* @param \OCA\News\Utility\Config $config
|
||||
* @internal param \OCA\News\ArticleEnhancer\a $SimplePieFileFactory factory for getting a simple pie file instance
|
||||
* @internal param int $maximumTimeout maximum timeout in seconds, defaults to 10 sec
|
||||
*/
|
||||
public function __construct(SimplePieAPIFactory $fileFactory,
|
||||
array $regexXPathPair, Config $config){
|
||||
$this->regexXPathPair = $regexXPathPair;
|
||||
|
|
|
@ -19,6 +19,8 @@ use OCP\BackgroundJob\IJobList;
|
|||
use OCP\INavigationManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use \OCP\Backgroundjob;
|
||||
use \OCP\Util;
|
||||
|
||||
|
||||
// Used to parse app.json file, should be in core at some point
|
||||
|
@ -136,7 +138,7 @@ class AppConfig {
|
|||
// FIXME: this is temporarily static because core jobs are not public
|
||||
// yet, therefore legacy code
|
||||
foreach ($this->config['jobs'] as $job) {
|
||||
\OCP\Backgroundjob::addRegularTask($job, 'run');
|
||||
Backgroundjob::addRegularTask($job, 'run');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +154,7 @@ class AppConfig {
|
|||
$reaction = explode('::', $react);
|
||||
|
||||
// config is written like HookNamespace::method => Class::method
|
||||
\OCP\Util::connectHook($listener[0], $listener[1], $reaction[0],
|
||||
Util::connectHook($listener[0], $listener[1], $reaction[0],
|
||||
$reaction[1]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,13 @@ class EntityApiSerializer {
|
|||
|
||||
/**
|
||||
* Call toAPI() method on all entities. Works on
|
||||
* @param mixed $data:
|
||||
*
|
||||
* @param mixed $data :
|
||||
* * Entity
|
||||
* * Entity[]
|
||||
* * array('level' => Entity[])
|
||||
* * Response
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function serialize($data) {
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ class FeedApiController extends ApiController {
|
|||
public function index() {
|
||||
|
||||
$result = [
|
||||
'feeds' => [],
|
||||
'starredCount' => $this->itemService->starredCount($this->userId),
|
||||
'feeds' => $this->feedService->findAll($this->userId)
|
||||
];
|
||||
|
@ -76,14 +75,15 @@ class FeedApiController extends ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $folderId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $folderId
|
||||
* @return array|mixed|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function create($url, $folderId=0) {
|
||||
try {
|
||||
$this->feedService->purgeDeleted($this->userId, false);
|
||||
|
@ -107,19 +107,22 @@ class FeedApiController extends ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function delete($feedId) {
|
||||
try {
|
||||
$this->feedService->delete($feedId, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,37 +139,43 @@ class FeedApiController extends ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param int $folderId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param int $folderId
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function move($feedId, $folderId) {
|
||||
try {
|
||||
$this->feedService->move($feedId, $folderId, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $feedTitle
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $feedTitle
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function rename($feedId, $feedTitle) {
|
||||
try {
|
||||
$this->feedService->rename($feedId, $feedTitle, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -118,13 +118,14 @@ class FeedController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $parentFolderId
|
||||
* @param string $title
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $url
|
||||
* @param int $parentFolderId
|
||||
* @param string $title
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function create($url, $parentFolderId, $title){
|
||||
try {
|
||||
// we need to purge deleted feeds if a feed is created to
|
||||
|
@ -150,28 +151,33 @@ class FeedController extends Controller {
|
|||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function delete($feedId){
|
||||
try {
|
||||
$this->feedService->markDeleted($feedId, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function update($feedId){
|
||||
try {
|
||||
$feed = $this->feedService->update($feedId, $this->userId);
|
||||
|
@ -190,43 +196,51 @@ class FeedController extends Controller {
|
|||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param int $parentFolderId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param int $parentFolderId
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function move($feedId, $parentFolderId){
|
||||
try {
|
||||
$this->feedService->move($feedId, $parentFolderId, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $feedTitle
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $feedTitle
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function rename($feedId, $feedTitle) {
|
||||
try {
|
||||
$this->feedService->rename($feedId, $feedTitle, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param array $json
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param array $json
|
||||
* @return array
|
||||
*/
|
||||
public function import($json) {
|
||||
$feed = $this->feedService->importArticles($json, $this->userId);
|
||||
|
||||
|
@ -240,12 +254,13 @@ class FeedController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param int $highestItemId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param int $highestItemId
|
||||
* @return array
|
||||
*/
|
||||
public function read($feedId, $highestItemId){
|
||||
$this->itemService->readFeed($feedId, $highestItemId, $this->userId);
|
||||
|
||||
|
@ -260,17 +275,20 @@ class FeedController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function restore($feedId){
|
||||
try {
|
||||
$this->feedService->unmarkDeleted($feedId, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,13 +58,14 @@ class FolderApiController extends ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param string $name
|
||||
* @return array|mixed|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function create($name) {
|
||||
try {
|
||||
$this->folderService->purgeDeleted($this->userId, false);
|
||||
|
@ -79,29 +80,33 @@ class FolderApiController extends ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $folderId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $folderId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function delete($folderId) {
|
||||
try {
|
||||
$this->folderService->delete($folderId, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
* @param int $folderId
|
||||
* @param string $name
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
* @param int $folderId
|
||||
* @param string $name
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function update($folderId, $name) {
|
||||
try {
|
||||
$this->folderService->rename($folderId, $name, $this->userId);
|
||||
|
@ -113,6 +118,8 @@ class FolderApiController extends ApiController {
|
|||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,26 +57,30 @@ class FolderController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
* @param bool $open
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
* @param bool $open
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function open($folderId, $open) {
|
||||
try {
|
||||
$this->folderService->open($folderId, $open, $this->userId);
|
||||
} catch(ServiceNotFoundException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $folderName
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $folderName
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function create($folderName) {
|
||||
try {
|
||||
// we need to purge deleted folders if a folder is created to
|
||||
|
@ -95,26 +99,30 @@ class FolderController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function delete($folderId) {
|
||||
try {
|
||||
$this->folderService->markDeleted($folderId, $this->userId);
|
||||
} catch (ServiceNotFoundException $ex){
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $folderName
|
||||
* @param int $folderId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param string $folderName
|
||||
* @param int $folderId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function rename($folderName, $folderId) {
|
||||
try {
|
||||
$folder = $this->folderService->rename($folderId, $folderName,
|
||||
|
@ -129,14 +137,16 @@ class FolderController extends Controller {
|
|||
} catch (ServiceNotFoundException $ex){
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
* @param int $highestItemId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
* @param int $highestItemId
|
||||
* @return array
|
||||
*/
|
||||
public function read($folderId, $highestItemId) {
|
||||
$this->itemService->readFolder($folderId, $highestItemId, $this->userId);
|
||||
|
||||
|
@ -144,17 +154,20 @@ class FolderController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $folderId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function restore($folderId) {
|
||||
try {
|
||||
$this->folderService->unmarkDeleted($folderId, $this->userId);
|
||||
} catch (ServiceNotFoundException $ex){
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,18 +39,19 @@ class ItemApiController extends ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param bool $getRead
|
||||
* @param int $batchSize
|
||||
* @param int $offset
|
||||
* @param int $oldestFirst
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param bool $getRead
|
||||
* @param int $batchSize
|
||||
* @param int $offset
|
||||
* @param bool $oldestFirst
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function index($type, $id, $getRead, $batchSize=20, $offset=0,
|
||||
$oldestFirst=false) {
|
||||
return $this->serializer->serialize(
|
||||
|
@ -62,15 +63,16 @@ class ItemApiController extends ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param int $lastModified
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param int $lastModified
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function updated($type, $id, $lastModified=0) {
|
||||
return $this->serializer->serialize(
|
||||
$this->itemService->findAllNew($id, $type, $lastModified,
|
||||
|
@ -85,28 +87,32 @@ class ItemApiController extends ApiController {
|
|||
} catch(ServiceNotFoundException $ex){
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $itemId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $itemId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function read($itemId) {
|
||||
return $this->setRead(true, $itemId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $itemId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $itemId
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function unread($itemId) {
|
||||
return $this->setRead(false, $itemId);
|
||||
}
|
||||
|
@ -118,30 +124,34 @@ class ItemApiController extends ApiController {
|
|||
} catch(ServiceNotFoundException $ex){
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $guidHash
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $guidHash
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function star($feedId, $guidHash) {
|
||||
return $this->setStarred(true, $feedId, $guidHash);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $guidHash
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @CORS
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $guidHash
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function unstar($feedId, $guidHash) {
|
||||
return $this->setStarred(false, $feedId, $guidHash);
|
||||
}
|
||||
|
@ -178,7 +188,7 @@ class ItemApiController extends ApiController {
|
|||
* @param int[] item ids
|
||||
*/
|
||||
public function readMultiple($items) {
|
||||
return $this->setMultipleRead(true, $items);
|
||||
$this->setMultipleRead(true, $items);
|
||||
}
|
||||
|
||||
|
||||
|
@ -190,7 +200,7 @@ class ItemApiController extends ApiController {
|
|||
* @param int[] item ids
|
||||
*/
|
||||
public function unreadMultiple($items) {
|
||||
return $this->setMultipleRead(false, $items);
|
||||
$this->setMultipleRead(false, $items);
|
||||
}
|
||||
|
||||
|
||||
|
@ -214,7 +224,7 @@ class ItemApiController extends ApiController {
|
|||
* @param int[] item ids
|
||||
*/
|
||||
public function starMultiple($items) {
|
||||
return $this->setMultipleStarred(true, $items);
|
||||
$this->setMultipleStarred(true, $items);
|
||||
}
|
||||
|
||||
|
||||
|
@ -226,7 +236,7 @@ class ItemApiController extends ApiController {
|
|||
* @param int[] item ids
|
||||
*/
|
||||
public function unstarMultiple($items) {
|
||||
return $this->setMultipleStarred(false, $items);
|
||||
$this->setMultipleStarred(false, $items);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -46,14 +46,15 @@ class ItemController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param int $limit
|
||||
* @param int $offset
|
||||
* @return array
|
||||
*/
|
||||
public function index($type, $id, $limit=50, $offset=0) {
|
||||
$showAll = $this->settings->getUserValue($this->userId, $this->appName,
|
||||
'showAll') === '1';
|
||||
|
@ -92,13 +93,14 @@ class ItemController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param int $lastModified
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $id
|
||||
* @param int $lastModified
|
||||
* @return array
|
||||
*/
|
||||
public function newItems($type, $id, $lastModified=0) {
|
||||
$showAll = $this->settings->getUserValue($this->userId, $this->appName,
|
||||
'showAll') === '1';
|
||||
|
@ -120,13 +122,14 @@ class ItemController extends Controller {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $guidHash
|
||||
* @param bool $isStarred
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $feedId
|
||||
* @param string $guidHash
|
||||
* @param bool $isStarred
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function star($feedId, $guidHash, $isStarred){
|
||||
try {
|
||||
$this->itemService->star($feedId, $guidHash, $isStarred,
|
||||
|
@ -134,29 +137,35 @@ class ItemController extends Controller {
|
|||
} catch(ServiceException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $itemId
|
||||
* @param bool $isRead
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $itemId
|
||||
* @param bool $isRead
|
||||
* @return array|\OCP\AppFramework\Http\JSONResponse
|
||||
*/
|
||||
public function read($itemId, $isRead=true){
|
||||
try {
|
||||
$this->itemService->read($itemId, $isRead, $this->userId);
|
||||
} catch(ServiceException $ex) {
|
||||
return $this->error($ex, Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $highestItemId
|
||||
*/
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*
|
||||
* @param int $highestItemId
|
||||
* @return array
|
||||
*/
|
||||
public function readAll($highestItemId){
|
||||
$this->itemService->readAll($highestItemId, $this->userId);
|
||||
return ['feeds' => $this->feedService->findAll($this->userId)];
|
||||
|
|
|
@ -18,7 +18,7 @@ trait JSONHttpError {
|
|||
|
||||
|
||||
/**
|
||||
* @param \Excpetion $exception the message that is returned taken from the
|
||||
* @param \Exception $exception the message that is returned taken from the
|
||||
* exception
|
||||
* @param int the http error code
|
||||
* @return \OCP\AppFramework\Http\JSONResponse
|
||||
|
|
|
@ -23,7 +23,6 @@ use \OCP\AppFramework\Db\Entity;
|
|||
* @method string getUrlHash()
|
||||
* @method void setUrlHash(string $value)
|
||||
* @method string getUrl()
|
||||
* @method void setUrl(string $value)
|
||||
* @method string getTitle()
|
||||
* @method void setTitle(string $value)
|
||||
* @method string getFaviconLink()
|
||||
|
@ -35,7 +34,6 @@ use \OCP\AppFramework\Db\Entity;
|
|||
* @method integer getUnreadCount()
|
||||
* @method void setUnreadCount(integer $value)
|
||||
* @method string getLink()
|
||||
* @method void setLink(string $value)
|
||||
* @method boolean getPreventUpdate()
|
||||
* @method void setPreventUpdate(boolean $value)
|
||||
* @method integer getDeletedAt()
|
||||
|
|
|
@ -22,17 +22,12 @@ use \OCP\AppFramework\Db\Entity;
|
|||
* @method string getGuidHash()
|
||||
* @method void setGuidHash(string $value)
|
||||
* @method string getGuid()
|
||||
* @method void setGuid(string $value)
|
||||
* @method string getUrl()
|
||||
* @method void setUrl(string $value)
|
||||
* @method string getTitle()
|
||||
* @method void setTitle(string $value)
|
||||
* @method string getAuthor()
|
||||
* @method void setAuthor(string $value)
|
||||
* @method integer getPubDate()
|
||||
* @method void setPubDate(integer $value)
|
||||
* @method string getBody()
|
||||
* @method void setBody(string $value)
|
||||
* @method string getEnclosureMime()
|
||||
* @method void setEnclosureMime(string $value)
|
||||
* @method string getEnclosureLink()
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace OCA\News\Db;
|
|||
|
||||
use \OCP\IConfig;
|
||||
use \OCP\IDb;
|
||||
|
||||
use \OCA\News\Db\Postgres\ItemMapper as PostgresItemMapper;
|
||||
|
||||
class MapperFactory {
|
||||
|
||||
|
@ -31,7 +31,7 @@ class MapperFactory {
|
|||
public function getItemMapper() {
|
||||
switch($this->dbType) {
|
||||
case 'pgsql':
|
||||
return new \OCA\News\Db\Postgres\ItemMapper($this->db);
|
||||
return new PostgresItemMapper($this->db);
|
||||
default:
|
||||
return new ItemMapper($this->db);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ class Fetcher {
|
|||
return $fetcher->fetch($url, $getFavicon);
|
||||
}
|
||||
}
|
||||
|
||||
return [null, []];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ class FeedService extends Service {
|
|||
$existingFeed = $this->feedMapper->find($feedId, $userId);
|
||||
|
||||
if($existingFeed->getPreventUpdate() === true) {
|
||||
return;
|
||||
return $existingFeed;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -223,6 +223,7 @@ class FeedService extends Service {
|
|||
} catch (DoesNotExistException $ex){
|
||||
throw new ServiceNotFoundException('Feed does not exist');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -317,6 +318,8 @@ class FeedService extends Service {
|
|||
if($createdFeed) {
|
||||
return $this->feedMapper->findByUrlHash($urlHash, $userId);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace OCA\News\Service;
|
|||
|
||||
use \OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
||||
use \OCA\News\Db\Item;
|
||||
use \OCA\News\Db\ItemMapper;
|
||||
use \OCA\News\Db\StatusFlag;
|
||||
use \OCA\News\Db\FeedType;
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
<div class="enclosure" ng-if="item.enclosureLink">
|
||||
<news-audio type="{{ item.enclosureType }}"
|
||||
ng-src="{{ item.enclosureLink|trustUrl }}"/>
|
||||
ng-src="{{ item.enclosureLink|trustUrl }}">
|
||||
<?php p($l->t('Download')) ?>
|
||||
</news-audio>
|
||||
</div>
|
||||
|
|
|
@ -62,9 +62,9 @@
|
|||
</h2>
|
||||
|
||||
<div class="enclosure" ng-if="item.enclosureLink">
|
||||
<news-audio type="{{ item.enclosureType }}" ng-src="{{ item.enclosureLink|trustUrl }}"/><?php
|
||||
<news-audio type="{{ item.enclosureType }}" ng-src="{{ item.enclosureLink|trustUrl }}"><?php
|
||||
p($l->t('Download'))
|
||||
?></audio>
|
||||
?></news-audio>
|
||||
</div>
|
||||
|
||||
<div class="body" news-bind-html-unsafe="item.body">
|
||||
|
|
Загрузка…
Ссылка в новой задаче