diff --git a/lib/Database.php b/lib/Database.php index 127cbcec..ac319cd1 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -435,7 +435,7 @@ class Database { // Add each of the articles to the database. foreach($feed->data->items as $i) { - $this->articleAdd($i); + $this->articleAdd($feedID, $i); } } @@ -450,10 +450,10 @@ class Database { return (bool) $this->db->prepare("DELETE from arsse_subscriptions where owner is ? and id is ?", "str", "int")->run($user, $id)->changes(); } - public function articleAdd(PicoFeed\Parser\Item $article): int { + public function articleAdd(int $feedID, \PicoFeed\Parser\Item $article): int { $this->db->begin(); - $articleId = $this->db->prepare('INSERT INTO arsse_articles(feed,url,title,author,published,edited,guid,content,url_title_hash,url_content_hash,title_content_hash) + $articleID = $this->db->prepare('INSERT INTO arsse_articles(feed,url,title,author,published,edited,guid,content,url_title_hash,url_content_hash,title_content_hash) values(?,?,?,?,?,?,?,?,?,?,?)', 'int', 'str', 'str', 'str', 'datetime', 'datetime', 'str', 'str', 'str', 'str', 'str')->run( $feedID, @@ -470,23 +470,24 @@ class Database { )->lastId(); // If the article has categories add them into the categories database. - $this->categoriesAdd($article, $articleID); + $this->categoriesAdd($articleID, $article); $this->db->commit(); return 1; } - public function categoriesAdd(PicoFeed\Parser\Item $article, int $id): int { + public function categoriesAdd(int $articleID, \PicoFeed\Parser\Item $article): int { $this->db->begin(); $categories = $article->getTag('category'); if(count($categories) > 0) { foreach($categories as $c) { - $this->db->prepare('INSERT INTO arsse_categories(article,name) values(?,?)', 'int', 'str')->run($id, $c); + $this->db->prepare('INSERT INTO arsse_categories(article,name) values(?,?)', 'int', 'str')->run($articleID, $c); } } $this->db->commit(); + return count($categories); } public function updateFeeds(): int { diff --git a/lib/Feed.php b/lib/Feed.php index 3eecbce3..1c606b17 100644 --- a/lib/Feed.php +++ b/lib/Feed.php @@ -20,7 +20,7 @@ class Feed { $config->setGrabberUserAgent(Data::$conf->userAgentString); $this->reader = new Reader($config); - $this->resource = $reader->download($url, $lastModified, $etag, $username, $password); + $this->resource = $this->reader->download($url, $lastModified, $etag, $username, $password); // Grab the favicon for the feed; returns an empty string if it cannot find one. $this->favicon = (new Favicon)->find($url); } catch (PicoFeedException $e) { @@ -31,11 +31,10 @@ class Feed { public function parse(): bool { try { $this->parser = $this->reader->getParser( - $resource->getUrl(), - $resource->getContent(), - $resource->getEncoding() + $this->resource->getUrl(), + $this->resource->getContent(), + $this->resource->getEncoding() ); - $feed = $this->parser->execute(); } catch (PicoFeedException $e) { throw new Feed\Exception($url, $e); @@ -51,9 +50,9 @@ class Feed { foreach ($feed->items as &$f) { // Hashes used for comparison to check for updates and also to identify when an // id doesn't exist. - $f->urlTitleHash = hash('sha256', $i->url.$i->title); - $f->urlContentHash = hash('sha256', $i->url.$i->content.$i->enclosureUrl.$i->enclosureType); - $f->titleContentHash = hash('sha256', $i->title.$i->content.$i->enclosureUrl.$i->enclosureType); + $f->urlTitleHash = hash('sha256', $f->url.$f->title); + $f->urlContentHash = hash('sha256', $f->url.$f->content.$f->enclosureUrl.$f->enclosureType); + $f->titleContentHash = hash('sha256', $f->title.$f->content.$f->enclosureUrl.$f->enclosureType); // If there is an id element then continue. The id is used already. $id = (string)$f->xml->id; diff --git a/lib/REST.php b/lib/REST.php index 41693cc9..0edfb538 100644 --- a/lib/REST.php +++ b/lib/REST.php @@ -24,7 +24,6 @@ class REST { // Fever https://feedafever.com/api // NewsBlur http://www.newsblur.com/api ]; - protected $data; function __construct() { } diff --git a/lib/REST/NextCloudNews/V1_2.php b/lib/REST/NextCloudNews/V1_2.php new file mode 100644 index 00000000..d68c3e62 --- /dev/null +++ b/lib/REST/NextCloudNews/V1_2.php @@ -0,0 +1,20 @@ +parseURL($req->url)); + if(preg_match("<^/(items|folders|feeds|cleanup|version|status|user)(?:/([^/]+))?(?:/([^/]+))?(?:/([^/]+))?/?$>", $path, $matches)) { + $scope = $matches[1]; + var_export($scope); + } else { + return new Response(404); + } + } +} \ No newline at end of file