1
1
Fork 0

Merge pull request #9017 from annando/issue-9015

Issue 9015: Reducing load of remote systems
This commit is contained in:
Hypolite Petovan 2020-08-15 18:23:28 -04:00 committed by GitHub
commit 977e4fe5d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 32 deletions

View file

@ -1355,7 +1355,7 @@ class Item
* @param array $item * @param array $item
* @return boolean item is valid * @return boolean item is valid
*/ */
private static function isValid(array $item) public static function isValid(array $item)
{ {
// When there is no content then we don't post it // When there is no content then we don't post it
if ($item['body'].$item['title'] == '') { if ($item['body'].$item['title'] == '') {
@ -1384,7 +1384,7 @@ class Item
} }
} }
if (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;
} }
@ -1394,12 +1394,12 @@ class Item
return false; return false;
} }
if (!empty($item['uid']) && Contact\User::isBlocked($item['author-id'], $item['uid'])) { if (!empty($item['uid']) && !empty($item['author-id']) && Contact\User::isBlocked($item['author-id'], $item['uid'])) {
Logger::notice('Author is blocked by user', ['author-link' => $item['author-link'], 'uid' => $item['uid'], 'item-uri' => $item['uri']]); Logger::notice('Author is blocked by user', ['author-link' => $item['author-link'], 'uid' => $item['uid'], 'item-uri' => $item['uri']]);
return false; return false;
} }
if (Contact::isBlocked($item['owner-id'])) { if (!empty($item['owner-id']) && Contact::isBlocked($item['owner-id'])) {
Logger::notice('Owner is blocked node-wide', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]); Logger::notice('Owner is blocked node-wide', ['owner-link' => $item['owner-link'], 'item-uri' => $item['uri']]);
return false; return false;
} }
@ -1409,7 +1409,7 @@ class Item
return false; return false;
} }
if (!empty($item['uid']) && Contact\User::isBlocked($item['owner-id'], $item['uid'])) { if (!empty($item['uid']) && !empty($item['owner-id']) && Contact\User::isBlocked($item['owner-id'], $item['uid'])) {
Logger::notice('Owner is blocked by user', ['owner-link' => $item['owner-link'], 'uid' => $item['uid'], 'item-uri' => $item['uri']]); Logger::notice('Owner is blocked by user', ['owner-link' => $item['owner-link'], 'uid' => $item['uid'], 'item-uri' => $item['uri']]);
return false; return false;
} }

View file

@ -1547,7 +1547,7 @@ class Transmitter
*/ */
public static function isAnnounce($item) public static function isAnnounce($item)
{ {
if ($item['verb'] == Activity::ANNOUNCE) { if (!empty($item['verb']) && ($item['verb'] == Activity::ANNOUNCE)) {
return true; return true;
} }

View file

@ -35,7 +35,6 @@ use Friendica\Model\Contact;
use Friendica\Model\Item; use Friendica\Model\Item;
use Friendica\Model\Tag; use Friendica\Model\Tag;
use Friendica\Model\User; use Friendica\Model\User;
use Friendica\Network\HTTPRequest;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\ParseUrl; use Friendica\Util\ParseUrl;
@ -496,6 +495,14 @@ class Feed
$item["title"] = ''; $item["title"] = '';
} }
if ($dryRun) {
$items[] = $item;
break;
} elseif (!Item::isValid($item)) {
Logger::info('Feed is invalid', ['created' => $item['created'], 'uid' => $item['uid'], 'uri' => $item['uri']]);
continue;
}
$preview = ''; $preview = '';
if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) { if (!empty($contact["fetch_further_information"]) && ($contact["fetch_further_information"] < 3)) {
// Handle enclosures and treat them as preview picture // Handle enclosures and treat them as preview picture
@ -564,10 +571,6 @@ class Feed
} }
} }
if ($dryRun) {
$items[] = $item;
break;
} else {
Logger::info('Stored feed', ['item' => $item]); Logger::info('Stored feed', ['item' => $item]);
$notify = Item::isRemoteSelf($contact, $item); $notify = Item::isRemoteSelf($contact, $item);
@ -594,7 +597,6 @@ class Feed
} }
} }
} }
}
return ["header" => $author, "items" => $items]; return ["header" => $author, "items" => $items];
} }

View file

@ -181,7 +181,7 @@ class Cron
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function pollContacts() { private static function pollContacts() {
$min_poll_interval = DI::config()->get('system', 'min_poll_interval', 1); $min_poll_interval = DI::config()->get('system', 'min_poll_interval');
Addon::reload(); Addon::reload();

View file

@ -60,7 +60,7 @@ class OnePoll
return; return;
} }
if (($contact['network'] != Protocol::MAIL) || $force) { if (($contact['network'] != Protocol::MAIL) && $force) {
Contact::updateFromProbe($contact_id); Contact::updateFromProbe($contact_id);
} }

View file

@ -331,7 +331,7 @@ return [
// min_poll_interval (Integer) // min_poll_interval (Integer)
// minimal distance in minutes between two polls for a contact. Reasonable values are between 1 and 59. // minimal distance in minutes between two polls for a contact. Reasonable values are between 1 and 59.
'min_poll_interval' => 1, 'min_poll_interval' => 15,
// no_count (Boolean) // no_count (Boolean)
// Don't do count calculations (currently only when showing photo albums). // Don't do count calculations (currently only when showing photo albums).