Reduce the load of "gfollower"

This commit is contained in:
Michael 2020-03-10 21:10:59 +00:00
parent 2b5ef80912
commit f27900ad78
9 changed files with 50 additions and 10 deletions

View file

@ -1621,6 +1621,9 @@ class Contact
// Update the gcontact entry
if ($uid == 0) {
GContact::updateFromPublicContactID($contact_id);
if (($data['network'] == Protocol::ACTIVITYPUB) && in_array(DI::config()->get('system', 'gcontact_discovery'), [GContact::DISCOVERY_DIRECT, GContact::DISCOVERY_RECURSIVE])) {
GContact::discoverFollowers($data['url']);
}
}
}
} else {

View file

@ -43,6 +43,19 @@ use Friendica\Util\Strings;
*/
class GContact
{
/**
* No discovery of followers/followings
*/
const DISCOVERY_NONE = 0;
/**
* Only discover followers/followings from direct contacts
*/
const DISCOVERY_DIRECT = 1;
/**
* Recursive discovery of followers/followings
*/
const DISCOVERY_RECURSIVE = 2;
/**
* Search global contact table by nick or name
*

View file

@ -1695,7 +1695,7 @@ class Item
$fields = ['uri', 'parent-uri', 'id', 'deleted',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'wall', 'private', 'forum_mode', 'origin'];
'wall', 'private', 'forum_mode', 'origin', 'author-id'];
$condition = ['uri' => $item['parent-uri'], 'uid' => $item['uid']];
$params = ['order' => ['id' => false]];
$parent = self::selectFirst($fields, $condition, $params);
@ -1750,7 +1750,15 @@ class Item
DBA::update('thread', ['mention' => true], ['iid' => $parent_id]);
Logger::log('tagged thread ' . $parent_id . ' as mention for user ' . $item['uid'], Logger::DEBUG);
}
} else {
// Update the contact relations
if ($item['author-id'] != $parent['author-id']) {
$fields = ['cid' => $parent['author-id'], 'relation-cid' => $item['author-id']];
if (!DBA::exists('contact-relation', $fields)) {
DBA::insert('contact-relation', $fields, true);
}
}
} else {
/*
* Allow one to see reply tweets from status.net even when
* we don't have or can't see the original post.