From 7a50ec4815071842cd3833eda564b7efbad6c4e5 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 27 Sep 2020 11:55:31 +0000 Subject: [PATCH] Only update public contacts that are in use --- src/Worker/UpdatePublicContacts.php | 7 +++++++ static/defaults.config.php | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/Worker/UpdatePublicContacts.php b/src/Worker/UpdatePublicContacts.php index 453606bfa..519478e11 100644 --- a/src/Worker/UpdatePublicContacts.php +++ b/src/Worker/UpdatePublicContacts.php @@ -25,6 +25,7 @@ use Friendica\Core\Logger; use Friendica\Core\Protocol; use Friendica\Core\Worker; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Util\DateTimeFormat; /** @@ -39,6 +40,12 @@ class UpdatePublicContacts $condition = ["`network` IN (?, ?, ?, ?) AND `uid` = ? AND NOT `self` AND `last-update` < ?", Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, 0, $last_updated]; + if (DI::config()->get('system', 'update_active_contacts')) { + $condition = DBA::mergeConditions($condition, ["(`id` IN (SELECT `author-id` FROM `item`) OR + `id` IN (SELECT `owner-id` FROM `item`) OR `id` IN (SELECT `causer-id` FROM `item`) OR + `id` IN (SELECT `cid` FROM `post-tag`) OR `id` IN (SELECT `cid` FROM `user-contact`))"]); + } + $oldest_date = ''; $oldest_id = ''; $contacts = DBA::select('contact', ['id', 'last-update'], $condition, ['limit' => 100, 'order' => ['last-update']]); diff --git a/static/defaults.config.php b/static/defaults.config.php index fbd3787b7..11731f214 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -475,6 +475,10 @@ return [ // Maximum number of posts that a user can send per month with the API. 0 to disable monthly throttling. 'throttle_limit_month' => 0, + // update_active_contacts (Boolean) + // When activated, only public contacts will be activated regularly that are used for example in items or tags. + 'update_active_contacts' => false, + // username_min_length (Integer) // The minimum character length a username can be. // This length is check once the username has been trimmed and multiple spaces have been collapsed into one.