summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appinfo/database.xml6
-rw-r--r--appinfo/version2
-rw-r--r--businesslayer/feedbusinesslayer.php15
-rw-r--r--db/feed.php2
-rw-r--r--tests/unit/businesslayer/FeedBusinessLayerTest.php20
5 files changed, 38 insertions, 7 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml
index 300f6a2db..3198b402d 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -111,6 +111,12 @@
<type>integer</type>
<notnull>true</notnull>
</field>
+ <field>
+ <name>preventUpdate</name>
+ <type>boolean</type>
+ <default>false</default>
+ <notnull>true</notnull>
+ </field>
<index>
<name>news_feeds_user_id_index</name>
diff --git a/appinfo/version b/appinfo/version
index 0dc0f32d5..223a93930 100644
--- a/appinfo/version
+++ b/appinfo/version
@@ -1 +1 @@
-8.2 \ No newline at end of file
+8.3 \ No newline at end of file
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php
index 983a4768a..9f3635e8a 100644
--- a/businesslayer/feedbusinesslayer.php
+++ b/businesslayer/feedbusinesslayer.php
@@ -118,18 +118,21 @@ class FeedBusinessLayer extends BusinessLayer {
public function update($feedId, $userId){
try {
$existingFeed = $this->mapper->find($feedId, $userId);
+
+ if($existingFeed->getPreventUpdate() === true) {
+ return;
+ }
+
try {
- list($feed, $items) = $this->feedFetcher->fetch($existingFeed->getUrl());
+ list($feed, $items) = $this->feedFetcher->fetch(
+ $existingFeed->getUrl());
- // insert items in reverse order because the first one is usually the
- // newest item
+ // insert items in reverse order because the first one is usually
+ // the newest item
for($i=count($items)-1; $i>=0; $i--){
$item = $items[$i];
$item->setFeedId($existingFeed->getId());
- // if a doesnotexist exception is being thrown the entry does not
- // exist and the item needs to be created, otherwise
- // update it
try {
$existing = $this->itemMapper->findByGuidHash(
$item->getGuidHash(), $feedId, $userId);
diff --git a/db/feed.php b/db/feed.php
index 824aed501..e2d3b87de 100644
--- a/db/feed.php
+++ b/db/feed.php
@@ -39,12 +39,14 @@ class Feed extends Entity {
public $folderId;
public $unreadCount;
public $link;
+ public $preventUpdate;
public function __construct(){
$this->addType('parentId', 'int');
$this->addType('added', 'int');
$this->addType('folderId', 'int');
$this->addType('unreadCount', 'int');
+ $this->addType('preventUpdate', 'bool');
}
} \ No newline at end of file
diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php
index 0b147c837..465dda8cb 100644
--- a/tests/unit/businesslayer/FeedBusinessLayerTest.php
+++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php
@@ -480,6 +480,26 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
}
+ public function testUpdateDoesntUpdateIfFeedIsPrevented() {
+ $feedId = 3;
+ $folderId = 4;
+ $feed = new Feed();
+ $feed->setFolderId(16);
+ $feed->setId($feedId);
+ $feed->setPreventUpdate(true);
+
+ $this->mapper->expects($this->once())
+ ->method('find')
+ ->with($this->equalTo($feedId),
+ $this->equalTo($this->user))
+ ->will($this->returnValue($feed));
+ $this->fetcher->expects($this->never())
+ ->method('fetch');
+
+ $this->businessLayer->update($feedId, $this->user);
+ }
+
+
public function testMove(){
$feedId = 3;
$folderId = 4;