mirror of
https://github.com/friendica/friendica
synced 2025-02-05 11:38:51 +00:00
Improved performance on relation discovery
This commit is contained in:
parent
df85a9a63a
commit
d45cd93278
1 changed files with 11 additions and 7 deletions
|
@ -10,6 +10,7 @@ namespace Friendica\Model\Contact;
|
|||
use Exception;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
|
@ -21,6 +22,7 @@ use Friendica\Model\Verb;
|
|||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
|
@ -162,20 +164,22 @@ class Relation
|
|||
$following_counter = 0;
|
||||
|
||||
DI::logger()->info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]);
|
||||
foreach ($contacts as $contact) {
|
||||
$actor = Contact::getIdForURL($contact);
|
||||
if (!empty($actor)) {
|
||||
if (in_array($contact, $followers)) {
|
||||
$fields = ['cid' => $target, 'relation-cid' => $actor, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
foreach ($contacts as $contact_url) {
|
||||
$contact = Contact::getByURL($contact_url, false, ['id']);
|
||||
if (!empty($contact['id'])) {
|
||||
if (in_array($contact_url, $followers)) {
|
||||
$fields = ['cid' => $target, 'relation-cid' => $contact['id'], 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
|
||||
$follower_counter++;
|
||||
}
|
||||
|
||||
if (in_array($contact, $followings)) {
|
||||
$fields = ['cid' => $actor, 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
if (in_array($contact_url, $followings)) {
|
||||
$fields = ['cid' => $contact['id'], 'relation-cid' => $target, 'follows' => true, 'follow-updated' => DateTimeFormat::utcNow()];
|
||||
DBA::insert('contact-relation', $fields, Database::INSERT_UPDATE);
|
||||
$following_counter++;
|
||||
}
|
||||
} elseif (!Network::isUrlBlocked($contact_url)) {
|
||||
Worker::add(Worker::PRIORITY_LOW, 'AddContact', 0, $contact_url);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue