mirror of
https://github.com/friendica/friendica
synced 2025-04-17 18:30:12 +00:00
Merge pull request #14699 from annando/update-contact
New option to only update contacts that have got a relation to local users
This commit is contained in:
commit
15cec1ac10
8 changed files with 889 additions and 811 deletions
|
@ -362,10 +362,8 @@ class Contact
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
|
|
||||||
|
|
||||||
// Update the contact in the background if needed
|
// Update the contact in the background if needed
|
||||||
if ($background_update && !self::isLocal($url) && Protocol::supportsProbe($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
|
if (UpdateContact::isUpdatable($contact['id'])) {
|
||||||
try {
|
try {
|
||||||
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
|
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
@ -537,6 +535,17 @@ class Contact
|
||||||
return DBA::exists('account-user-view', ["`pid` = ? AND `uid` != ? AND `rel` IN (?, ?)", $cid, 0, self::SHARING, self::FRIEND]);
|
return DBA::exists('account-user-view', ["`pid` = ? AND `uid` != ? AND `rel` IN (?, ?)", $cid, 0, self::SHARING, self::FRIEND]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the provided public contact id has got relations with someone on this system
|
||||||
|
*
|
||||||
|
* @param integer $cid Public Contact Id
|
||||||
|
* @return boolean Contact has followers or sharers on this system
|
||||||
|
*/
|
||||||
|
public static function hasRelations(int $cid): bool
|
||||||
|
{
|
||||||
|
return DBA::exists('account-user-view', ["`pid` = ? AND `uid` != ? AND `rel` IN (?, ?, ?)", $cid, 0, self::FOLLOWER, self::SHARING, self::FRIEND]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the basepath for a given contact link
|
* Get the basepath for a given contact link
|
||||||
*
|
*
|
||||||
|
@ -1318,9 +1327,7 @@ class Contact
|
||||||
if (!empty($contact)) {
|
if (!empty($contact)) {
|
||||||
$contact_id = $contact['id'];
|
$contact_id = $contact['id'];
|
||||||
|
|
||||||
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
|
if (UpdateContact::isUpdatable($contact['id'])) {
|
||||||
|
|
||||||
if ($background_update && !self::isLocal($url) && Protocol::supportsProbe($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
|
|
||||||
try {
|
try {
|
||||||
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
|
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
|
|
@ -450,9 +450,11 @@ class GServer
|
||||||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
|
$gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
|
||||||
if (DBA::isResult($gserver)) {
|
if (DBA::isResult($gserver)) {
|
||||||
$next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
|
$next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
|
||||||
self::update(['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
self::update(
|
||||||
|
['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
||||||
'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
|
'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
|
||||||
['nurl' => $nurl]);
|
['nurl' => $nurl]
|
||||||
|
);
|
||||||
DI::logger()->info('Set failed status for existing server', ['url' => $url]);
|
DI::logger()->info('Set failed status for existing server', ['url' => $url]);
|
||||||
if (self::isDefunct($gserver)) {
|
if (self::isDefunct($gserver)) {
|
||||||
self::archiveContacts($gserver['id']);
|
self::archiveContacts($gserver['id']);
|
||||||
|
@ -803,6 +805,7 @@ class GServer
|
||||||
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
|
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
|
||||||
if (!DBA::isResult($gserver)) {
|
if (!DBA::isResult($gserver)) {
|
||||||
$serverdata['created'] = DateTimeFormat::utcNow();
|
$serverdata['created'] = DateTimeFormat::utcNow();
|
||||||
|
|
||||||
$ret = self::insert($serverdata);
|
$ret = self::insert($serverdata);
|
||||||
$id = DBA::lastInsertId();
|
$id = DBA::lastInsertId();
|
||||||
} else {
|
} else {
|
||||||
|
@ -982,6 +985,7 @@ class GServer
|
||||||
|
|
||||||
if (!empty($data['version'])) {
|
if (!empty($data['version'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$serverdata['version'] = $data['version'];
|
$serverdata['version'] = $data['version'];
|
||||||
// Version numbers on statistics.json are presented with additional info, e.g.:
|
// Version numbers on statistics.json are presented with additional info, e.g.:
|
||||||
// 0.6.3.0-p1702cc1c, 0.6.99.0-p1b9ab160 or 3.4.3-2-1191.
|
// 0.6.3.0-p1702cc1c, 0.6.99.0-p1b9ab160 or 3.4.3-2-1191.
|
||||||
|
@ -990,11 +994,13 @@ class GServer
|
||||||
|
|
||||||
if (!empty($data['name'])) {
|
if (!empty($data['name'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$serverdata['site_name'] = $data['name'];
|
$serverdata['site_name'] = $data['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['network'])) {
|
if (!empty($data['network'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$serverdata['platform'] = strtolower($data['network']);
|
$serverdata['platform'] = strtolower($data['network']);
|
||||||
|
|
||||||
if ($serverdata['platform'] == 'diaspora') {
|
if ($serverdata['platform'] == 'diaspora') {
|
||||||
|
@ -1010,21 +1016,25 @@ class GServer
|
||||||
|
|
||||||
if (!empty($data['total_users'])) {
|
if (!empty($data['total_users'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$serverdata['registered-users'] = max($data['total_users'], 1);
|
$serverdata['registered-users'] = max($data['total_users'], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['active_users_monthly'])) {
|
if (!empty($data['active_users_monthly'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$serverdata['active-month-users'] = max($data['active_users_monthly'], 0);
|
$serverdata['active-month-users'] = max($data['active_users_monthly'], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['active_users_halfyear'])) {
|
if (!empty($data['active_users_halfyear'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$serverdata['active-halfyear-users'] = max($data['active_users_halfyear'], 0);
|
$serverdata['active-halfyear-users'] = max($data['active_users_halfyear'], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['local_posts'])) {
|
if (!empty($data['local_posts'])) {
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$serverdata['local-posts'] = max($data['local_posts'], 0);
|
$serverdata['local-posts'] = max($data['local_posts'], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1828,8 +1838,7 @@ class GServer
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['totalResults'])) {
|
if (!empty($data['totalResults'])) {
|
||||||
$registeredUsers = $serverdata['registered-users'] ?? 0;
|
$serverdata['registered-users'] = max($data['totalResults'], $serverdata['registered-users'] ?? 0, 1);
|
||||||
$serverdata['registered-users'] = max($data['totalResults'], $registeredUsers, 1);
|
|
||||||
$serverdata['directory-type'] = self::DT_POCO;
|
$serverdata['directory-type'] = self::DT_POCO;
|
||||||
$serverdata['poco'] = $url . '/poco';
|
$serverdata['poco'] = $url . '/poco';
|
||||||
}
|
}
|
||||||
|
@ -2014,6 +2023,7 @@ class GServer
|
||||||
$serverdata['platform'] = 'mastodon';
|
$serverdata['platform'] = 'mastodon';
|
||||||
$serverdata['version'] = $data['version'] ?? '';
|
$serverdata['version'] = $data['version'] ?? '';
|
||||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2024,6 +2034,7 @@ class GServer
|
||||||
if (!empty($data['title']) && empty($serverdata['platform']) && ($serverdata['network'] == Protocol::PHANTOM)) {
|
if (!empty($data['title']) && empty($serverdata['platform']) && ($serverdata['network'] == Protocol::PHANTOM)) {
|
||||||
$serverdata['platform'] = 'mastodon';
|
$serverdata['platform'] = 'mastodon';
|
||||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2038,18 +2049,21 @@ class GServer
|
||||||
if (!empty($serverdata['version']) && preg_match('/.*?\(compatible;\s(.*)\s(.*)\)/ism', $serverdata['version'], $matches)) {
|
if (!empty($serverdata['version']) && preg_match('/.*?\(compatible;\s(.*)\s(.*)\)/ism', $serverdata['version'], $matches)) {
|
||||||
$serverdata['platform'] = strtolower($matches[1]);
|
$serverdata['platform'] = strtolower($matches[1]);
|
||||||
$serverdata['version'] = $matches[2];
|
$serverdata['version'] = $matches[2];
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($serverdata['version']) && strstr(strtolower($serverdata['version']), 'pleroma')) {
|
if (!empty($serverdata['version']) && strstr(strtolower($serverdata['version']), 'pleroma')) {
|
||||||
$serverdata['platform'] = 'pleroma';
|
$serverdata['platform'] = 'pleroma';
|
||||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($serverdata['platform']) && strstr($serverdata['platform'], 'pleroma')) {
|
if (!empty($serverdata['platform']) && strstr($serverdata['platform'], 'pleroma')) {
|
||||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
|
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
|
||||||
$serverdata['platform'] = 'pleroma';
|
$serverdata['platform'] = 'pleroma';
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2317,12 +2331,14 @@ class GServer
|
||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
@$doc->loadHTML($curlResult->getBodyString());
|
@$doc->loadHTML($curlResult->getBodyString());
|
||||||
$xpath = new DOMXPath($doc);
|
$xpath = new DOMXPath($doc);
|
||||||
|
|
||||||
$assigned = false;
|
$assigned = false;
|
||||||
|
|
||||||
// We can only detect honk via some HTML element on their page
|
// We can only detect honk via some HTML element on their page
|
||||||
if ($xpath->query('//div[@id="honksonpage"]')->count() == 1) {
|
if ($xpath->query('//div[@id="honksonpage"]')->count() == 1) {
|
||||||
$serverdata['platform'] = 'honk';
|
$serverdata['platform'] = 'honk';
|
||||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||||
|
|
||||||
$assigned = true;
|
$assigned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2358,9 +2374,11 @@ class GServer
|
||||||
'twitter:app:name:googleplay', 'twitter:app:name:iphone', 'twitter:app:name:ipad', 'generator'])) {
|
'twitter:app:name:googleplay', 'twitter:app:name:iphone', 'twitter:app:name:ipad', 'generator'])) {
|
||||||
$platform = str_ireplace(array_keys($platforms), array_values($platforms), $attr['content']);
|
$platform = str_ireplace(array_keys($platforms), array_values($platforms), $attr['content']);
|
||||||
$platform = str_replace('/', ' ', $platform);
|
$platform = str_replace('/', ' ', $platform);
|
||||||
|
|
||||||
$platform_parts = explode(' ', $platform);
|
$platform_parts = explode(' ', $platform);
|
||||||
if ((count($platform_parts) >= 2) && in_array(strtolower($platform_parts[0]), array_values($platforms))) {
|
if ((count($platform_parts) >= 2) && in_array(strtolower($platform_parts[0]), array_values($platforms))) {
|
||||||
$platform = $platform_parts[0];
|
$platform = $platform_parts[0];
|
||||||
|
|
||||||
$serverdata['version'] = $platform_parts[1];
|
$serverdata['version'] = $platform_parts[1];
|
||||||
}
|
}
|
||||||
if (in_array($platform, array_values($grouped_platforms['dfrn_platforms']))) {
|
if (in_array($platform, array_values($grouped_platforms['dfrn_platforms']))) {
|
||||||
|
@ -2372,6 +2390,7 @@ class GServer
|
||||||
}
|
}
|
||||||
if (in_array($platform, array_values($platforms))) {
|
if (in_array($platform, array_values($platforms))) {
|
||||||
$serverdata['platform'] = $platform;
|
$serverdata['platform'] = $platform;
|
||||||
|
|
||||||
$assigned = true;
|
$assigned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2407,6 +2426,7 @@ class GServer
|
||||||
if (in_array($attr['property'], ['og:platform', 'generator'])) {
|
if (in_array($attr['property'], ['og:platform', 'generator'])) {
|
||||||
if (in_array($attr['content'], array_keys($platforms))) {
|
if (in_array($attr['content'], array_keys($platforms))) {
|
||||||
$serverdata['platform'] = $platforms[$attr['content']];
|
$serverdata['platform'] = $platforms[$attr['content']];
|
||||||
|
|
||||||
$assigned = true;
|
$assigned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2425,6 +2445,7 @@ class GServer
|
||||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||||
$serverdata['platform'] = 'microblog';
|
$serverdata['platform'] = 'microblog';
|
||||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||||
|
|
||||||
$assigned = true;
|
$assigned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2438,6 +2459,7 @@ class GServer
|
||||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||||
$serverdata['platform'] = 'microblog';
|
$serverdata['platform'] = 'microblog';
|
||||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||||
|
|
||||||
$assigned = true;
|
$assigned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2488,10 +2510,6 @@ class GServer
|
||||||
*/
|
*/
|
||||||
public static function discover()
|
public static function discover()
|
||||||
{
|
{
|
||||||
if (!DI::config()->get('system', 'discover_servers')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the server list
|
// Update the server list
|
||||||
self::discoverFederation();
|
self::discoverFederation();
|
||||||
|
|
||||||
|
@ -2501,9 +2519,12 @@ class GServer
|
||||||
|
|
||||||
$last_update = date('c', time() - (60 * 60 * 24 * $requery_days));
|
$last_update = date('c', time() - (60 * 60 * 24 * $requery_days));
|
||||||
|
|
||||||
$gservers = DBA::select('gserver', ['id', 'url', 'nurl', 'network', 'poco', 'directory-type'],
|
$gservers = DBA::select(
|
||||||
|
'gserver',
|
||||||
|
['id', 'url', 'nurl', 'network', 'poco', 'directory-type'],
|
||||||
["NOT `blocked` AND NOT `failed` AND `directory-type` != ? AND `last_poco_query` < ?", GServer::DT_NONE, $last_update],
|
["NOT `blocked` AND NOT `failed` AND `directory-type` != ? AND `last_poco_query` < ?", GServer::DT_NONE, $last_update],
|
||||||
['order' => ['RAND()']]);
|
['order' => ['RAND()']]
|
||||||
|
);
|
||||||
|
|
||||||
while ($gserver = DBA::fetch($gservers)) {
|
while ($gserver = DBA::fetch($gservers)) {
|
||||||
DI::logger()->info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
DI::logger()->info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
namespace Friendica\Module\Admin;
|
namespace Friendica\Module\Admin;
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Core\Renderer;
|
use Friendica\Core\Renderer;
|
||||||
use Friendica\Core\Search;
|
use Friendica\Core\Search;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
|
@ -20,7 +19,6 @@ use Friendica\Model\User;
|
||||||
use Friendica\Module\BaseAdmin;
|
use Friendica\Module\BaseAdmin;
|
||||||
use Friendica\Module\Conversation\Community;
|
use Friendica\Module\Conversation\Community;
|
||||||
use Friendica\Module\Register;
|
use Friendica\Module\Register;
|
||||||
use Friendica\Navigation\SystemMessages;
|
|
||||||
use Friendica\Protocol\Relay;
|
use Friendica\Protocol\Relay;
|
||||||
use Friendica\Util\BasePath;
|
use Friendica\Util\BasePath;
|
||||||
use Friendica\Util\EMailer\MailBuilder;
|
use Friendica\Util\EMailer\MailBuilder;
|
||||||
|
@ -105,6 +103,7 @@ class Site extends BaseAdmin
|
||||||
$optimize_tables = (!empty($_POST['optimize_tables']) ? intval(trim($_POST['optimize_tables'])) : false);
|
$optimize_tables = (!empty($_POST['optimize_tables']) ? intval(trim($_POST['optimize_tables'])) : false);
|
||||||
$contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : Contact\Relation::DISCOVERY_NONE);
|
$contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : Contact\Relation::DISCOVERY_NONE);
|
||||||
$update_active_contacts = (!empty($_POST['update_active_contacts']) ? intval(trim($_POST['update_active_contacts'])) : false);
|
$update_active_contacts = (!empty($_POST['update_active_contacts']) ? intval(trim($_POST['update_active_contacts'])) : false);
|
||||||
|
$update_known_contacts = (!empty($_POST['update_known_contacts']) ? intval(trim($_POST['update_known_contacts'])) : false);
|
||||||
$synchronize_directory = (!empty($_POST['synchronize_directory']) ? intval(trim($_POST['synchronize_directory'])) : false);
|
$synchronize_directory = (!empty($_POST['synchronize_directory']) ? intval(trim($_POST['synchronize_directory'])) : false);
|
||||||
$poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7);
|
$poco_requery_days = (!empty($_POST['poco_requery_days']) ? intval(trim($_POST['poco_requery_days'])) : 7);
|
||||||
$poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : false);
|
$poco_discovery = (!empty($_POST['poco_discovery']) ? intval(trim($_POST['poco_discovery'])) : false);
|
||||||
|
@ -141,7 +140,6 @@ class Site extends BaseAdmin
|
||||||
$worker_defer_limit = (!empty($_POST['worker_defer_limit']) ? intval($_POST['worker_defer_limit']) : 15);
|
$worker_defer_limit = (!empty($_POST['worker_defer_limit']) ? intval($_POST['worker_defer_limit']) : 15);
|
||||||
$worker_fetch_limit = (!empty($_POST['worker_fetch_limit']) ? intval($_POST['worker_fetch_limit']) : 1);
|
$worker_fetch_limit = (!empty($_POST['worker_fetch_limit']) ? intval($_POST['worker_fetch_limit']) : 1);
|
||||||
|
|
||||||
|
|
||||||
$relay_directly = !empty($_POST['relay_directly']);
|
$relay_directly = !empty($_POST['relay_directly']);
|
||||||
$relay_scope = (!empty($_POST['relay_scope']) ? trim($_POST['relay_scope']) : '');
|
$relay_scope = (!empty($_POST['relay_scope']) ? trim($_POST['relay_scope']) : '');
|
||||||
$relay_server_tags = (!empty($_POST['relay_server_tags']) ? trim($_POST['relay_server_tags']) : '');
|
$relay_server_tags = (!empty($_POST['relay_server_tags']) ? trim($_POST['relay_server_tags']) : '');
|
||||||
|
@ -178,6 +176,7 @@ class Site extends BaseAdmin
|
||||||
$transactionConfig->set('system', 'optimize_tables', $optimize_tables);
|
$transactionConfig->set('system', 'optimize_tables', $optimize_tables);
|
||||||
$transactionConfig->set('system', 'contact_discovery', $contact_discovery);
|
$transactionConfig->set('system', 'contact_discovery', $contact_discovery);
|
||||||
$transactionConfig->set('system', 'update_active_contacts', $update_active_contacts);
|
$transactionConfig->set('system', 'update_active_contacts', $update_active_contacts);
|
||||||
|
$transactionConfig->set('system', 'update_known_contacts', $update_known_contacts);
|
||||||
$transactionConfig->set('system', 'synchronize_directory', $synchronize_directory);
|
$transactionConfig->set('system', 'synchronize_directory', $synchronize_directory);
|
||||||
$transactionConfig->set('system', 'poco_requery_days', $poco_requery_days);
|
$transactionConfig->set('system', 'poco_requery_days', $poco_requery_days);
|
||||||
$transactionConfig->set('system', 'poco_discovery', $poco_discovery);
|
$transactionConfig->set('system', 'poco_discovery', $poco_discovery);
|
||||||
|
@ -546,6 +545,7 @@ class Site extends BaseAdmin
|
||||||
'<li>' . DI::l10n()->t('Interactors - contacts of our local contacts and contacts who interacted on locally visible postings are discovered for their followers/followings.') . '</li></ul>',
|
'<li>' . DI::l10n()->t('Interactors - contacts of our local contacts and contacts who interacted on locally visible postings are discovered for their followers/followings.') . '</li></ul>',
|
||||||
$discovery_choices],
|
$discovery_choices],
|
||||||
'$update_active_contacts' => ['update_active_contacts', DI::l10n()->t('Only update contacts/servers with local data'), DI::config()->get('system', 'update_active_contacts'), DI::l10n()->t('If enabled, the system will only look for changes in contacts and servers that engaged on this system by either being in a contact list of a user or when posts or comments exists from the contact on this system.')],
|
'$update_active_contacts' => ['update_active_contacts', DI::l10n()->t('Only update contacts/servers with local data'), DI::config()->get('system', 'update_active_contacts'), DI::l10n()->t('If enabled, the system will only look for changes in contacts and servers that engaged on this system by either being in a contact list of a user or when posts or comments exists from the contact on this system.')],
|
||||||
|
'$update_known_contacts' => ['update_known_contacts', DI::l10n()->t('Only update contacts with relations'), DI::config()->get('system', 'update_known_contacts'), DI::l10n()->t('If enabled, the system will only look for changes in contacts that are in a contact list of a user on this system.')],
|
||||||
'$synchronize_directory' => ['synchronize_directory', DI::l10n()->t('Synchronize the contacts with the directory server'), DI::config()->get('system', 'synchronize_directory'), DI::l10n()->t('if enabled, the system will check periodically for new contacts on the defined directory server.')],
|
'$synchronize_directory' => ['synchronize_directory', DI::l10n()->t('Synchronize the contacts with the directory server'), DI::config()->get('system', 'synchronize_directory'), DI::l10n()->t('if enabled, the system will check periodically for new contacts on the defined directory server.')],
|
||||||
|
|
||||||
'$poco_discovery' => ['poco_discovery', DI::l10n()->t('Discover contacts from other servers'), DI::config()->get('system', 'poco_discovery'), DI::l10n()->t('Periodically query other servers for contacts and servers that they know of. The system queries Friendica, Mastodon and Hubzilla servers. Keep it deactivated on small machines to decrease the database size and load.')],
|
'$poco_discovery' => ['poco_discovery', DI::l10n()->t('Discover contacts from other servers'), DI::config()->get('system', 'poco_discovery'), DI::l10n()->t('Periodically query other servers for contacts and servers that they know of. The system queries Friendica, Mastodon and Hubzilla servers. Keep it deactivated on small machines to decrease the database size and load.')],
|
||||||
|
|
|
@ -7,10 +7,12 @@
|
||||||
|
|
||||||
namespace Friendica\Worker;
|
namespace Friendica\Worker;
|
||||||
|
|
||||||
|
use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
|
use Friendica\Util\DateTimeFormat;
|
||||||
|
|
||||||
class UpdateContact
|
class UpdateContact
|
||||||
{
|
{
|
||||||
|
@ -54,4 +56,38 @@ class UpdateContact
|
||||||
DI::logger()->debug('Update contact', ['id' => $contact_id]);
|
DI::logger()->debug('Update contact', ['id' => $contact_id]);
|
||||||
return Worker::add($run_parameters, 'UpdateContact', $contact_id);
|
return Worker::add($run_parameters, 'UpdateContact', $contact_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isUpdatable(int $contact_id): bool
|
||||||
|
{
|
||||||
|
$contact = Contact::selectFirst(['next-update', 'local-data', 'url', 'network', 'uid'], ['id' => $contact_id]);
|
||||||
|
if (empty($contact)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($contact['next-update'] > DateTimeFormat::utcNow()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DI::config()->get('system', 'update_known_contacts') && ($contact['uid'] == 0) && !Contact::hasRelations($contact_id)) {
|
||||||
|
DI::logger()->debug('No local relations, contact will not be updated', ['id' => $contact_id, 'url' => $contact['url'], 'network' => $contact['network']]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DI::config()->get('system', 'update_active_contacts') && $contact['local-data']) {
|
||||||
|
DI::logger()->debug('No local data, contact will not be updated', ['id' => $contact_id, 'url' => $contact['url'], 'network' => $contact['network']]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Contact::isLocal($contact['url'])) {
|
||||||
|
DI::logger()->debug('Local contact will not be updated', ['id' => $contact_id, 'url' => $contact['url'], 'network' => $contact['network']]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Protocol::supportsProbe($contact['network'])) {
|
||||||
|
DI::logger()->debug('Contact does not support probe, it will not be updated', ['id' => $contact_id, 'url' => $contact['url'], 'network' => $contact['network']]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,10 @@ return [
|
||||||
// When activated, only public contacts will be activated regularly that are used for example in items or tags.
|
// When activated, only public contacts will be activated regularly that are used for example in items or tags.
|
||||||
'update_active_contacts' => false,
|
'update_active_contacts' => false,
|
||||||
|
|
||||||
|
// update_known_contacts (Boolean)
|
||||||
|
// When activated, only public contacts will be activated regularly that are in a contact list of a local user.
|
||||||
|
'update_known_contacts' => false,
|
||||||
|
|
||||||
// url (String)
|
// url (String)
|
||||||
// The fully-qualified URL of this Friendica node.
|
// The fully-qualified URL of this Friendica node.
|
||||||
// Used by the worker in a non-HTTP execution environment.
|
// Used by the worker in a non-HTTP execution environment.
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -112,6 +112,7 @@
|
||||||
<h2>{{$portable_contacts}}</h2>
|
<h2>{{$portable_contacts}}</h2>
|
||||||
{{include file="field_select.tpl" field=$contact_discovery}}
|
{{include file="field_select.tpl" field=$contact_discovery}}
|
||||||
{{include file="field_checkbox.tpl" field=$update_active_contacts}}
|
{{include file="field_checkbox.tpl" field=$update_active_contacts}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$update_known_contacts}}
|
||||||
{{include file="field_checkbox.tpl" field=$synchronize_directory}}
|
{{include file="field_checkbox.tpl" field=$synchronize_directory}}
|
||||||
{{include file="field_checkbox.tpl" field=$poco_discovery}}
|
{{include file="field_checkbox.tpl" field=$poco_discovery}}
|
||||||
{{include file="field_input.tpl" field=$poco_requery_days}}
|
{{include file="field_input.tpl" field=$poco_requery_days}}
|
||||||
|
|
|
@ -228,6 +228,7 @@
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
{{include file="field_select.tpl" field=$contact_discovery}}
|
{{include file="field_select.tpl" field=$contact_discovery}}
|
||||||
{{include file="field_checkbox.tpl" field=$update_active_contacts}}
|
{{include file="field_checkbox.tpl" field=$update_active_contacts}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$update_known_contacts}}
|
||||||
{{include file="field_checkbox.tpl" field=$synchronize_directory}}
|
{{include file="field_checkbox.tpl" field=$synchronize_directory}}
|
||||||
{{include file="field_checkbox.tpl" field=$poco_discovery}}
|
{{include file="field_checkbox.tpl" field=$poco_discovery}}
|
||||||
{{include file="field_input.tpl" field=$poco_requery_days}}
|
{{include file="field_input.tpl" field=$poco_requery_days}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue