Disable automatically duplicated feeds
This commit is contained in:
parent
e25a4d5cc8
commit
d3207cda53
@ -98,6 +98,10 @@ function update_feed($user_id, $feed_id)
|
||||
{
|
||||
$subscription = Model\Feed\get_feed($user_id, $feed_id);
|
||||
|
||||
if ($subscription['enabled'] == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($feed, $resource, $error_message) = fetch_feed(
|
||||
$subscription['feed_url'],
|
||||
(bool) $subscription['download_content'],
|
||||
@ -115,8 +119,14 @@ function update_feed($user_id, $feed_id)
|
||||
));
|
||||
|
||||
return false;
|
||||
} else if (Model\Feed\is_duplicated_feed($user_id, $feed_id, $resource->getUrl())) {
|
||||
Model\Feed\update_feed($user_id, $feed_id, array(
|
||||
'enabled' => 0,
|
||||
'last_checked' => time(),
|
||||
'parsing_error' => 1,
|
||||
'parsing_error_message' => t('Duplicated feed'),
|
||||
));
|
||||
} else {
|
||||
|
||||
Model\Feed\update_feed($user_id, $feed_id, array(
|
||||
'feed_url' => $resource->getUrl(),
|
||||
'etag' => $resource->getEtag(),
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
'Current Password' => 'Aktuální heslo',
|
||||
'New Password' => 'Nové heslo',
|
||||
'Wrong password' => 'Špatné heslo',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
'Current Password' => 'Mot de passe actuel',
|
||||
'New Password' => 'Nouveau mot de passe',
|
||||
'Wrong password' => 'Mauvais mot de passe',
|
||||
'Duplicated feed' => 'Abonnement dupliqué',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -256,4 +256,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
'Current Password' => 'Текущий пароль',
|
||||
'New Password' => 'Новый пароль',
|
||||
'Wrong password' => 'Неверный пароль',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
// 'Current Password' => '',
|
||||
// 'New Password' => '',
|
||||
// 'Wrong password' => '',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -254,4 +254,5 @@ return array(
|
||||
'Current Password' => '当前密码',
|
||||
'New Password' => '新密码',
|
||||
'Wrong password' => '密码错误',
|
||||
// 'Duplicated feed' => '',
|
||||
);
|
||||
|
@ -117,6 +117,16 @@ function get_feed($user_id, $feed_id)
|
||||
->findOne();
|
||||
}
|
||||
|
||||
function is_duplicated_feed($user_id, $feed_id, $feed_url)
|
||||
{
|
||||
return Database::getInstance('db')
|
||||
->table(TABLE)
|
||||
->eq('user_id', $user_id)
|
||||
->neq('id', $feed_id)
|
||||
->eq('feed_url', $feed_url)
|
||||
->exists();
|
||||
}
|
||||
|
||||
function update_feed($user_id, $feed_id, array $values)
|
||||
{
|
||||
$db = Database::getInstance('db');
|
||||
|
@ -12,9 +12,7 @@
|
||||
</div>
|
||||
|
||||
<?php if (empty($feeds)): ?>
|
||||
|
||||
<p class="alert alert-info"><?php echo t('No subscription') ?></p>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<?php if ($nothing_to_read): ?>
|
||||
@ -47,12 +45,11 @@
|
||||
<?php echo t('never updated after creation') ?>
|
||||
</span>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
<span class="feed-parsing-error">
|
||||
<?php echo t('An error occurred during the last check: "%s".', $feed['parsing_error_message']) ?>
|
||||
</span>
|
||||
|
||||
<?php endif ?>
|
||||
</h2>
|
||||
<ul class="item-menu">
|
||||
<li>
|
||||
|
@ -168,4 +168,27 @@ class FeedModelTest extends BaseTest
|
||||
$this->assertEquals(1, Model\Feed\create(1, $feed, 'etag', 'last modified'));
|
||||
$this->assertEquals(2, Model\Feed\create(2, $feed, 'etag', 'last modified'));
|
||||
}
|
||||
|
||||
public function testIsDuplicatedFeed()
|
||||
{
|
||||
$feed = new Feed();
|
||||
$feed->setTitle('My feed');
|
||||
$feed->setFeedUrl('feed url');
|
||||
$feed->setSiteUrl('site url');
|
||||
|
||||
$this->assertEquals(1, Model\Feed\create(1, $feed, 'etag', 'last modified'));
|
||||
|
||||
$feed = new Feed();
|
||||
$feed->setTitle('My feed');
|
||||
$feed->setFeedUrl('another feed url');
|
||||
$feed->setSiteUrl('site url');
|
||||
|
||||
$this->assertEquals(2, Model\Feed\create(1, $feed, 'etag', 'last modified'));
|
||||
|
||||
$this->assertFalse(Model\Feed\is_duplicated_feed(1, 1, 'feed url'));
|
||||
$this->assertTrue(Model\Feed\is_duplicated_feed(1, 1, 'another feed url'));
|
||||
|
||||
$this->assertFalse(Model\Feed\is_duplicated_feed(1, 2, 'another feed url'));
|
||||
$this->assertTrue(Model\Feed\is_duplicated_feed(1, 2, 'feed url'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user