summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2016-04-09 18:23:00 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2016-04-09 18:23:19 +0200
commit2d17054d766746456faf769c920c8674b5afc4e5 (patch)
tree47f729c3510d771a16d08c0fccaa4e75625e189a
parent78fee82a8447855ba549f4a0e52ddf0a1f1ab2be (diff)
add last modified fields for feed and folder and move etag and lastmodified to http_etag and http_last_modified columns
-rw-r--r--appinfo/database.xml20
-rw-r--r--appinfo/info.xml2
-rw-r--r--db/feed.php20
-rw-r--r--db/folder.php5
-rw-r--r--fetcher/feedfetcher.php4
-rw-r--r--service/feedservice.php13
-rw-r--r--tests/integration/fixtures/feedfixture.php5
-rw-r--r--tests/integration/fixtures/folderfixture.php2
-rw-r--r--tests/unit/db/FeedTest.php9
-rw-r--r--tests/unit/fetcher/FeedFetcherTest.php4
-rw-r--r--tests/unit/service/FeedServiceTest.php28
11 files changed, 72 insertions, 40 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml
index 9b6b36a3d..eb4e122c9 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -48,6 +48,14 @@
<notnull>false</notnull>
<unsigned>true</unsigned>
</field>
+ <field>
+ <name>last_modified</name>
+ <type>integer</type>
+ <default></default>
+ <length>8</length>
+ <notnull>false</notnull>
+ <unsigned>true</unsigned>
+ </field>
<index>
<name>news_folders_parent_id_index</name>
@@ -116,12 +124,12 @@
<notnull>false</notnull>
</field>
<field>
- <name>last_modified</name>
+ <name>http_last_modified</name>
<type>clob</type>
<notnull>false</notnull>
</field>
<field>
- <name>etag</name>
+ <name>http_etag</name>
<type>clob</type>
<notnull>false</notnull>
</field>
@@ -209,6 +217,14 @@
<default>0</default>
<notnull>true</notnull>
</field>
+ <field>
+ <name>last_modified</name>
+ <type>integer</type>
+ <default></default>
+ <length>8</length>
+ <notnull>false</notnull>
+ <unsigned>true</unsigned>
+ </field>
<index>
<name>news_feeds_user_id_index</name>
diff --git a/appinfo/info.xml b/appinfo/info.xml
index ca28101c7..1c33d413a 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -7,7 +7,7 @@
<author>Bernhard Posselt, Alessandro Cosentino, Jan-Christoph Borchardt</author>
<category>multimedia</category>
<licence>AGPL</licence>
- <version>8.2.1</version>
+ <version>8.2.2</version>
<namespace>News</namespace>
<!-- resources -->
diff --git a/db/feed.php b/db/feed.php
index f78b1f364..b339c2837 100644
--- a/db/feed.php
+++ b/db/feed.php
@@ -21,7 +21,7 @@ use \OCP\AppFramework\Db\Entity;
* @method string getUserId()
* @method void setUserId(string $value)
* @method int getOrdering()
- * @method void setOrdering(int $value)
+ * @method void setOrdering(integer $value)
* @method string getUrlHash()
* @method void setUrlHash(string $value)
* @method string getLocation()
@@ -30,9 +30,11 @@ use \OCP\AppFramework\Db\Entity;
* @method string getTitle()
* @method void setTitle(string $value)
* @method string getLastModified()
- * @method void setLastModified(string $value)
- * @method string getEtag()
- * @method void setEtag(string $value)
+ * @method void setLastModified(integer $value)
+ * @method string getHttpLastModified()
+ * @method void setHttpLastModified(string $value)
+ * @method string getHttpEtag()
+ * @method void setHttpEtag(string $value)
* @method string getFaviconLink()
* @method void setFaviconLink(string $value)
* @method integer getAdded()
@@ -78,7 +80,8 @@ class Feed extends Entity implements IAPI, \JsonSerializable {
protected $deletedAt;
protected $articlesPerUpdate;
protected $lastModified;
- protected $etag;
+ protected $httpLastModified;
+ protected $httpEtag;
protected $location;
protected $ordering;
protected $fullTextEnabled;
@@ -102,6 +105,7 @@ class Feed extends Entity implements IAPI, \JsonSerializable {
$this->addType('fullTextEnabled', 'boolean');
$this->addType('updateMode', 'integer');
$this->addType('updateErrorCount', 'integer');
+ $this->addType('lastModified', 'integer');
}
@@ -131,7 +135,8 @@ class Feed extends Entity implements IAPI, \JsonSerializable {
'updateErrorCount',
'lastUpdateError',
'basicAuthUser',
- 'basicAuthPassword'
+ 'basicAuthPassword',
+ 'lastModified'
]);
$url = parse_url($this->link)['host'];
@@ -158,7 +163,8 @@ class Feed extends Entity implements IAPI, \JsonSerializable {
'unreadCount',
'ordering',
'link',
- 'pinned'
+ 'pinned',
+ 'lastModified'
]);
}
diff --git a/db/folder.php b/db/folder.php
index 6d4af1aa3..8d1432a73 100644
--- a/db/folder.php
+++ b/db/folder.php
@@ -28,6 +28,9 @@ use \OCP\AppFramework\Db\Entity;
* @method void setOpened(boolean $value)
* @method integer getDeletedAt()
* @method void setDeletedAt(integer $value)
+ * @method integer getLastModified()
+ * @method void setLastModified(integer $value)
+
*/
class Folder extends Entity implements IAPI, \JsonSerializable {
@@ -38,11 +41,13 @@ class Folder extends Entity implements IAPI, \JsonSerializable {
protected $userId;
protected $opened;
protected $deletedAt;
+ protected $lastModified;
public function __construct(){
$this->addType('parentId', 'integer');
$this->addType('opened', 'boolean');
$this->addType('deletedAt', 'integer');
+ $this->addType('lastModified', 'integer');
}
/**
diff --git a/fetcher/feedfetcher.php b/fetcher/feedfetcher.php
index 18f0f8093..42cdfe0ba 100644
--- a/fetcher/feedfetcher.php
+++ b/fetcher/feedfetcher.php
@@ -237,8 +237,8 @@ class FeedFetcher implements IFeedFetcher {
$feed->setUrl($url); // the url used to add the feed
$feed->setLocation($location); // the url where the feed was found
$feed->setLink($link); // <link> attribute in the feed
- $feed->setLastModified($modified);
- $feed->setEtag($etag);
+ $feed->setHttpLastModified($modified);
+ $feed->setHttpEtag($etag);
$feed->setAdded($this->time->getTime());
if ($getFavicon) {
diff --git a/service/feedservice.php b/service/feedservice.php
index 19c0a3b4b..88087a874 100644
--- a/service/feedservice.php
+++ b/service/feedservice.php
@@ -204,8 +204,8 @@ class FeedService extends Service {
list($fetchedFeed, $items) = $this->feedFetcher->fetch(
$location,
false,
- $existingFeed->getLastModified(),
- $existingFeed->getEtag(),
+ $existingFeed->getHttpLastModified(),
+ $existingFeed->getHttpEtag(),
$existingFeed->getFullTextEnabled(),
$existingFeed->getBasicAuthUser(),
$existingFeed->getBasicAuthPassword()
@@ -228,8 +228,9 @@ class FeedService extends Service {
$existingFeed->setArticlesPerUpdate($itemCount);
}
- $existingFeed->setLastModified($fetchedFeed->getLastModified());
- $existingFeed->setEtag($fetchedFeed->getEtag());
+ $existingFeed->setHttpLastModified(
+ $fetchedFeed->getHttpLastModified());
+ $existingFeed->setHttpEtag($fetchedFeed->getHttpEtag());
$existingFeed->setLocation($fetchedFeed->getLocation());
// insert items in reverse order because the first one is
@@ -442,8 +443,8 @@ class FeedService extends Service {
// special feed updates
if (array_key_exists('fullTextEnabled', $diff)) {
// disable caching for the next update
- $feed->setEtag('');
- $feed->setLastModified(0);
+ $feed->setHttpEtag('');
+ $feed->setHttpLastModified(0);
$this->feedMapper->update($feed);
return $this->update($feedId, $userId, true);
}
diff --git a/tests/integration/fixtures/feedfixture.php b/tests/integration/fixtures/feedfixture.php
index cc8e2e159..25c1cbf46 100644
--- a/tests/integration/fixtures/feedfixture.php
+++ b/tests/integration/fixtures/feedfixture.php
@@ -33,8 +33,9 @@ class FeedFixture extends Feed {
'preventUpdate' => false,
'deletedAt' => 0,
'articlesPerUpdate' => 40,
- 'lastModified' => 10,
- 'etag' => '',
+ 'httpLastModified' => 10,
+ 'httpEtag' => '',
+ 'lastModified' => 9,
'location' => 'http://feed.com/rss',
'ordering' => 0,
'fullTextEnabled' => false,
diff --git a/tests/integration/fixtures/folderfixture.php b/tests/integration/fixtures/folderfixture.php
index 2c884c6ed..2dc6b3a44 100644
--- a/tests/integration/fixtures/folderfixture.php
+++ b/tests/integration/fixtures/folderfixture.php
@@ -26,7 +26,7 @@ class FolderFixture extends Folder {
'userId' => 'test',
'opened' => true,
'deletedAt' => 0,
-
+ 'lastModified' => 9
], $defaults);
unset($defaults['feeds']);
$this->fillDefaults($defaults);
diff --git a/tests/unit/db/FeedTest.php b/tests/unit/db/FeedTest.php
index d5f101c09..fdcdc3c53 100644
--- a/tests/unit/db/FeedTest.php
+++ b/tests/unit/db/FeedTest.php
@@ -20,8 +20,9 @@ class FeedTest extends \PHPUnit_Framework_TestCase {
private function createFeed() {
$feed = new Feed();
$feed->setId(3);
- $feed->setLastModified(44);
- $feed->setEtag(45);
+ $feed->setLastModified(43);
+ $feed->setHttpLastModified(44);
+ $feed->setHttpEtag(45);
$feed->setUrl('http://google.com/some/weird/path');
$feed->setTitle('title');
$feed->setFaviconLink('favicon');
@@ -55,6 +56,7 @@ class FeedTest extends \PHPUnit_Framework_TestCase {
'ordering' => 2,
'pinned' => true,
'link' => 'https://www.google.com/some/weird/path',
+ 'lastModified' => 43
], $feed->toAPI());
}
@@ -85,7 +87,8 @@ class FeedTest extends \PHPUnit_Framework_TestCase {
'updateErrorCount' => 2,
'lastUpdateError' => 'hi',
'basicAuthUser' => 'user',
- 'basicAuthPassword' => 'password'
+ 'basicAuthPassword' => 'password',
+ 'lastModified' => 43
], $feed->jsonSerialize());
}
diff --git a/tests/unit/fetcher/FeedFetcherTest.php b/tests/unit/fetcher/FeedFetcherTest.php
index f6a03afa2..33383910e 100644
--- a/tests/unit/fetcher/FeedFetcherTest.php
+++ b/tests/unit/fetcher/FeedFetcherTest.php
@@ -249,8 +249,8 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase {
$feed->setUrl($this->url);
$feed->setLink($this->feedLink);
$feed->setAdded($this->time);
- $feed->setLastModified($this->modified);
- $feed->setEtag($this->etag);
+ $feed->setHttpLastModified($this->modified);
+ $feed->setHttpEtag($this->etag);
$feed->setLocation($this->location);
if($hasFavicon) {
diff --git a/tests/unit/service/FeedServiceTest.php b/tests/unit/service/FeedServiceTest.php
index a6cee6159..efd7e5f33 100644
--- a/tests/unit/service/FeedServiceTest.php
+++ b/tests/unit/service/FeedServiceTest.php
@@ -252,8 +252,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$feed->setLink('http://test');
$feed->setUrl('http://test');
$feed->setUrlHash('yo');
- $feed->setLastModified(3);
- $feed->setEtag(4);
+ $feed->setHttpLastModified(3);
+ $feed->setHttpEtag(4);
$item = new Item();
$item->setGuidHash(md5('hi'));
@@ -313,8 +313,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$feed->setLink('http://test');
$feed->setUrl('http://test');
$feed->setUrlHash('yo');
- $feed->setLastModified(3);
- $feed->setEtag(4);
+ $feed->setHttpLastModified(3);
+ $feed->setHttpEtag(4);
$item = new Item();
$item->setGuidHash(md5('hi'));
@@ -374,8 +374,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$feed->setLink('http://test');
$feed->setUrl('http://test');
$feed->setUrlHash('yo');
- $feed->setLastModified(3);
- $feed->setEtag(4);
+ $feed->setHttpLastModified(3);
+ $feed->setHttpEtag(4);
return $feed;
}
@@ -574,8 +574,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$feed = new Feed();
$feed->setId(3);
$feed->setUrl('https://goo.com');
- $feed->setEtag('abc');
- $feed->setLastModified(123);
+ $feed->setHttpEtag('abc');
+ $feed->setHttpLastModified(123);
$feed->setFullTextEnabled(true);
$ex = new DoesNotExistException('');
@@ -590,8 +590,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
->method('fetch')
->with($this->equalTo($feed->getUrl()),
$this->equalTo(false),
- $this->equalTo($feed->getLastModified()),
- $this->equalTo($feed->getEtag()),
+ $this->equalTo($feed->getHttpLastModified()),
+ $this->equalTo($feed->getHttpEtag()),
$this->equalTo($feed->getFullTextEnabled()))
->will($this->throwException($ex));
@@ -997,8 +997,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
public function testPatchEnableFullText() {
$feed = Feed::fromRow([
'id' => 3,
- 'etag' => 'a',
- 'last_modified' => 1,
+ 'http_etag' => 'a',
+ 'http_last_modified' => 1,
'full_text_enabled' => false
]);
$feed2 = Feed::fromRow(['id' => 3]);
@@ -1009,8 +1009,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
->will($this->returnValue($feed));
$feed2->setFullTextEnabled(true);
- $feed2->setEtag('');
- $feed2->setLastModified(0);
+ $feed2->setHttpEtag('');
+ $feed2->setHttpLastModified(0);
$this->feedMapper->expects($this->at(1))
->method('update')
->with($this->equalTo($feed2));