Issue 8943: Only check for too old postings for feeds
This commit is contained in:
parent
fe79aaf7f8
commit
8bc799ff38
2 changed files with 36 additions and 22 deletions
|
@ -1382,27 +1382,6 @@ class Item
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for create date and expire time
|
|
||||||
$expire_interval = DI::config()->get('system', 'dbclean-expire-days', 0);
|
|
||||||
|
|
||||||
$user = DBA::selectFirst('user', ['expire'], ['uid' => $item['uid']]);
|
|
||||||
if (DBA::isResult($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
|
|
||||||
$expire_interval = $user['expire'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($expire_interval > 0) && !empty($item['created'])) {
|
|
||||||
$expire_date = time() - ($expire_interval * 86400);
|
|
||||||
$created_date = strtotime($item['created']);
|
|
||||||
if ($created_date < $expire_date) {
|
|
||||||
Logger::notice('Item created before expiration interval.', [
|
|
||||||
'created' => date('c', $created_date),
|
|
||||||
'expired' => date('c', $expire_date),
|
|
||||||
'$item' => $item
|
|
||||||
]);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($item['author-id']) && Contact::isBlocked($item['author-id'])) {
|
if (!empty($item['author-id']) && Contact::isBlocked($item['author-id'])) {
|
||||||
Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1446,6 +1425,38 @@ class Item
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the item array is too old
|
||||||
|
*
|
||||||
|
* @param array $item
|
||||||
|
* @return boolean item is too old
|
||||||
|
*/
|
||||||
|
public static function tooOld(array $item)
|
||||||
|
{
|
||||||
|
// check for create date and expire time
|
||||||
|
$expire_interval = DI::config()->get('system', 'dbclean-expire-days', 0);
|
||||||
|
|
||||||
|
$user = DBA::selectFirst('user', ['expire'], ['uid' => $item['uid']]);
|
||||||
|
if (DBA::isResult($user) && ($user['expire'] > 0) && (($user['expire'] < $expire_interval) || ($expire_interval == 0))) {
|
||||||
|
$expire_interval = $user['expire'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($expire_interval > 0) && !empty($item['created'])) {
|
||||||
|
$expire_date = time() - ($expire_interval * 86400);
|
||||||
|
$created_date = strtotime($item['created']);
|
||||||
|
if ($created_date < $expire_date) {
|
||||||
|
Logger::notice('Item created before expiration interval.', [
|
||||||
|
'created' => date('c', $created_date),
|
||||||
|
'expired' => date('c', $expire_date),
|
||||||
|
'$item' => $item
|
||||||
|
]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the id of the given item array if it has been stored before
|
* Return the id of the given item array if it has been stored before
|
||||||
*
|
*
|
||||||
|
|
|
@ -503,7 +503,10 @@ class Feed
|
||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
break;
|
break;
|
||||||
} elseif (!Item::isValid($item)) {
|
} elseif (!Item::isValid($item)) {
|
||||||
Logger::info('Feed is invalid', ['created' => $item['created'], 'uid' => $item['uid'], 'uri' => $item['uri']]);
|
Logger::info('Feed item is invalid', ['created' => $item['created'], 'uid' => $item['uid'], 'uri' => $item['uri']]);
|
||||||
|
continue;
|
||||||
|
} elseif (Item::tooOld($item)) {
|
||||||
|
Logger::info('Feed is too old', ['created' => $item['created'], 'uid' => $item['uid'], 'uri' => $item['uri']]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue