added a way to prevent feed from being updated

This commit is contained in:
Bernhard Posselt 2013-04-19 13:01:44 +02:00
Родитель 67e00e798d
Коммит 76cc72393a
5 изменённых файлов: 39 добавлений и 8 удалений

Просмотреть файл

@ -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>

Просмотреть файл

@ -1 +1 @@
8.2
8.3

Просмотреть файл

@ -118,18 +118,21 @@ class FeedBusinessLayer extends BusinessLayer {
public function update($feedId, $userId){
try {
$existingFeed = $this->mapper->find($feedId, $userId);
try {
list($feed, $items) = $this->feedFetcher->fetch($existingFeed->getUrl());
// insert items in reverse order because the first one is usually the
// newest item
if($existingFeed->getPreventUpdate() === true) {
return;
}
try {
list($feed, $items) = $this->feedFetcher->fetch(
$existingFeed->getUrl());
// 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);

Просмотреть файл

@ -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');
}
}

Просмотреть файл

@ -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;