diff options
Diffstat (limited to 'businesslayer/feedbusinesslayer.php')
-rw-r--r-- | businesslayer/feedbusinesslayer.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php index f7666fc1c..ec6d7283a 100644 --- a/businesslayer/feedbusinesslayer.php +++ b/businesslayer/feedbusinesslayer.php @@ -72,14 +72,25 @@ class FeedBusinessLayer extends BusinessLayer { // insert items in reverse order because the first one is usually the // newest item + $unreadCount = 0; for($i=count($items)-1; $i>=0; $i--){ $item = $items[$i]; $item->setFeedId($feed->getId()); - $this->itemMapper->insert($item); + + // check if item exists (guidhash is the same) + // and ignore it if it does + try { + $this->itemMapper->findByGuidHash( + $item->getGuidHash(), $item->getFeedId(), $userId); + continue; + } catch(DoesNotExistException $ex){ + $unreadCount += 1; + $this->itemMapper->insert($item); + } } // set unread count - $feed->setUnreadCount(count($items)); + $feed->setUnreadCount($unreadCount); return $feed; } catch(FetcherException $ex){ |