mirror of
https://github.com/friendica/friendica
synced 2025-01-30 22:59:47 +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 [];
|
||||
}
|
||||
|
||||
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
|
||||
|
||||
// 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 {
|
||||
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
|
||||
} 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]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
@ -1318,9 +1327,7 @@ class Contact
|
|||
if (!empty($contact)) {
|
||||
$contact_id = $contact['id'];
|
||||
|
||||
$background_update = DI::config()->get('system', 'update_active_contacts') ? $contact['local-data'] : true;
|
||||
|
||||
if ($background_update && !self::isLocal($url) && Protocol::supportsProbe($contact['network']) && ($contact['next-update'] < DateTimeFormat::utcNow())) {
|
||||
if (UpdateContact::isUpdatable($contact['id'])) {
|
||||
try {
|
||||
UpdateContact::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], $contact['id']);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
|
|
|
@ -450,9 +450,11 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
$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],
|
||||
['nurl' => $nurl]);
|
||||
['nurl' => $nurl]
|
||||
);
|
||||
DI::logger()->info('Set failed status for existing server', ['url' => $url]);
|
||||
if (self::isDefunct($gserver)) {
|
||||
self::archiveContacts($gserver['id']);
|
||||
|
@ -803,6 +805,7 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
|
||||
if (!DBA::isResult($gserver)) {
|
||||
$serverdata['created'] = DateTimeFormat::utcNow();
|
||||
|
||||
$ret = self::insert($serverdata);
|
||||
$id = DBA::lastInsertId();
|
||||
} else {
|
||||
|
@ -982,6 +985,7 @@ class GServer
|
|||
|
||||
if (!empty($data['version'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['version'] = $data['version'];
|
||||
// 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.
|
||||
|
@ -990,11 +994,13 @@ class GServer
|
|||
|
||||
if (!empty($data['name'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['site_name'] = $data['name'];
|
||||
}
|
||||
|
||||
if (!empty($data['network'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['platform'] = strtolower($data['network']);
|
||||
|
||||
if ($serverdata['platform'] == 'diaspora') {
|
||||
|
@ -1010,21 +1016,25 @@ class GServer
|
|||
|
||||
if (!empty($data['total_users'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['registered-users'] = max($data['total_users'], 1);
|
||||
}
|
||||
|
||||
if (!empty($data['active_users_monthly'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['active-month-users'] = max($data['active_users_monthly'], 0);
|
||||
}
|
||||
|
||||
if (!empty($data['active_users_halfyear'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['active-halfyear-users'] = max($data['active_users_halfyear'], 0);
|
||||
}
|
||||
|
||||
if (!empty($data['local_posts'])) {
|
||||
$valid = true;
|
||||
|
||||
$serverdata['local-posts'] = max($data['local_posts'], 0);
|
||||
}
|
||||
|
||||
|
@ -1828,8 +1838,7 @@ class GServer
|
|||
}
|
||||
|
||||
if (!empty($data['totalResults'])) {
|
||||
$registeredUsers = $serverdata['registered-users'] ?? 0;
|
||||
$serverdata['registered-users'] = max($data['totalResults'], $registeredUsers, 1);
|
||||
$serverdata['registered-users'] = max($data['totalResults'], $serverdata['registered-users'] ?? 0, 1);
|
||||
$serverdata['directory-type'] = self::DT_POCO;
|
||||
$serverdata['poco'] = $url . '/poco';
|
||||
}
|
||||
|
@ -2014,6 +2023,7 @@ class GServer
|
|||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['version'] = $data['version'] ?? '';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
|
@ -2024,6 +2034,7 @@ class GServer
|
|||
if (!empty($data['title']) && empty($serverdata['platform']) && ($serverdata['network'] == Protocol::PHANTOM)) {
|
||||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
|
@ -2038,18 +2049,21 @@ class GServer
|
|||
if (!empty($serverdata['version']) && preg_match('/.*?\(compatible;\s(.*)\s(.*)\)/ism', $serverdata['version'], $matches)) {
|
||||
$serverdata['platform'] = strtolower($matches[1]);
|
||||
$serverdata['version'] = $matches[2];
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($serverdata['version']) && strstr(strtolower($serverdata['version']), 'pleroma')) {
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($serverdata['platform']) && strstr($serverdata['platform'], 'pleroma')) {
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
|
@ -2317,12 +2331,14 @@ class GServer
|
|||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($curlResult->getBodyString());
|
||||
$xpath = new DOMXPath($doc);
|
||||
|
||||
$assigned = false;
|
||||
|
||||
// We can only detect honk via some HTML element on their page
|
||||
if ($xpath->query('//div[@id="honksonpage"]')->count() == 1) {
|
||||
$serverdata['platform'] = 'honk';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
|
||||
|
@ -2358,9 +2374,11 @@ class GServer
|
|||
'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_replace('/', ' ', $platform);
|
||||
|
||||
$platform_parts = explode(' ', $platform);
|
||||
if ((count($platform_parts) >= 2) && in_array(strtolower($platform_parts[0]), array_values($platforms))) {
|
||||
$platform = $platform_parts[0];
|
||||
|
||||
$serverdata['version'] = $platform_parts[1];
|
||||
}
|
||||
if (in_array($platform, array_values($grouped_platforms['dfrn_platforms']))) {
|
||||
|
@ -2372,6 +2390,7 @@ class GServer
|
|||
}
|
||||
if (in_array($platform, array_values($platforms))) {
|
||||
$serverdata['platform'] = $platform;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
|
@ -2407,6 +2426,7 @@ class GServer
|
|||
if (in_array($attr['property'], ['og:platform', 'generator'])) {
|
||||
if (in_array($attr['content'], array_keys($platforms))) {
|
||||
$serverdata['platform'] = $platforms[$attr['content']];
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
|
||||
|
@ -2425,6 +2445,7 @@ class GServer
|
|||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['platform'] = 'microblog';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
|
@ -2438,6 +2459,7 @@ class GServer
|
|||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['platform'] = 'microblog';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
|
@ -2488,10 +2510,6 @@ class GServer
|
|||
*/
|
||||
public static function discover()
|
||||
{
|
||||
if (!DI::config()->get('system', 'discover_servers')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the server list
|
||||
self::discoverFederation();
|
||||
|
||||
|
@ -2501,9 +2519,12 @@ class GServer
|
|||
|
||||
$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],
|
||||
['order' => ['RAND()']]);
|
||||
['order' => ['RAND()']]
|
||||
);
|
||||
|
||||
while ($gserver = DBA::fetch($gservers)) {
|
||||
DI::logger()->info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\Admin;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Search;
|
||||
use Friendica\Core\System;
|
||||
|
@ -20,7 +19,6 @@ use Friendica\Model\User;
|
|||
use Friendica\Module\BaseAdmin;
|
||||
use Friendica\Module\Conversation\Community;
|
||||
use Friendica\Module\Register;
|
||||
use Friendica\Navigation\SystemMessages;
|
||||
use Friendica\Protocol\Relay;
|
||||
use Friendica\Util\BasePath;
|
||||
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);
|
||||
$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_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);
|
||||
$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);
|
||||
|
@ -141,7 +140,6 @@ class Site extends BaseAdmin
|
|||
$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);
|
||||
|
||||
|
||||
$relay_directly = !empty($_POST['relay_directly']);
|
||||
$relay_scope = (!empty($_POST['relay_scope']) ? trim($_POST['relay_scope']) : '');
|
||||
$relay_server_tags = (!empty($_POST['relay_server_tags']) ? trim($_POST['relay_server_tags']) : '');
|
||||
|
@ -173,23 +171,24 @@ class Site extends BaseAdmin
|
|||
$diaspora_enabled = false;
|
||||
}
|
||||
|
||||
$transactionConfig->set('system', 'maxloadavg' , $maxloadavg);
|
||||
$transactionConfig->set('system', 'min_memory' , $min_memory);
|
||||
$transactionConfig->set('system', 'optimize_tables' , $optimize_tables);
|
||||
$transactionConfig->set('system', 'contact_discovery' , $contact_discovery);
|
||||
$transactionConfig->set('system', 'update_active_contacts' , $update_active_contacts);
|
||||
$transactionConfig->set('system', 'synchronize_directory' , $synchronize_directory);
|
||||
$transactionConfig->set('system', 'poco_requery_days' , $poco_requery_days);
|
||||
$transactionConfig->set('system', 'poco_discovery' , $poco_discovery);
|
||||
$transactionConfig->set('system', 'poco_local_search' , $poco_local_search);
|
||||
$transactionConfig->set('system', 'nodeinfo' , $nodeinfo);
|
||||
$transactionConfig->set('system', 'maxloadavg', $maxloadavg);
|
||||
$transactionConfig->set('system', 'min_memory', $min_memory);
|
||||
$transactionConfig->set('system', 'optimize_tables', $optimize_tables);
|
||||
$transactionConfig->set('system', 'contact_discovery', $contact_discovery);
|
||||
$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', 'poco_requery_days', $poco_requery_days);
|
||||
$transactionConfig->set('system', 'poco_discovery', $poco_discovery);
|
||||
$transactionConfig->set('system', 'poco_local_search', $poco_local_search);
|
||||
$transactionConfig->set('system', 'nodeinfo', $nodeinfo);
|
||||
if (DI::config()->isWritable('config', 'sitename')) {
|
||||
$transactionConfig->set('config', 'sitename', $sitename);
|
||||
}
|
||||
$transactionConfig->set('config', 'sender_email' , $sender_email);
|
||||
$transactionConfig->set('system', 'suppress_tags' , $suppress_tags);
|
||||
$transactionConfig->set('system', 'shortcut_icon' , $shortcut_icon);
|
||||
$transactionConfig->set('system', 'touch_icon' , $touch_icon);
|
||||
$transactionConfig->set('config', 'sender_email', $sender_email);
|
||||
$transactionConfig->set('system', 'suppress_tags', $suppress_tags);
|
||||
$transactionConfig->set('system', 'shortcut_icon', $shortcut_icon);
|
||||
$transactionConfig->set('system', 'touch_icon', $touch_icon);
|
||||
|
||||
if ($banner == "") {
|
||||
$transactionConfig->delete('system', 'banner');
|
||||
|
@ -234,60 +233,60 @@ class Site extends BaseAdmin
|
|||
} else {
|
||||
DI::sysmsg()->addNotice(DI::l10n()->t('%s is no valid input for maximum image size', $maximagesize));
|
||||
}
|
||||
$transactionConfig->set('system', 'max_image_length' , $maximagelength);
|
||||
$transactionConfig->set('system', 'jpeg_quality' , $jpegimagequality);
|
||||
$transactionConfig->set('system', 'max_image_length', $maximagelength);
|
||||
$transactionConfig->set('system', 'jpeg_quality', $jpegimagequality);
|
||||
|
||||
$transactionConfig->set('config', 'register_policy' , $register_policy);
|
||||
$transactionConfig->set('config', 'max_registered_users' , $max_registered_users);
|
||||
$transactionConfig->set('config', 'register_policy', $register_policy);
|
||||
$transactionConfig->set('config', 'max_registered_users', $max_registered_users);
|
||||
$transactionConfig->set('system', 'max_daily_registrations', $daily_registrations);
|
||||
|
||||
User::setRegisterMethodByUserCount();
|
||||
|
||||
$transactionConfig->set('system', 'account_abandon_days' , $abandon_days);
|
||||
$transactionConfig->set('config', 'register_text' , $register_text);
|
||||
$transactionConfig->set('system', 'allowed_sites' , $allowed_sites);
|
||||
$transactionConfig->set('system', 'allowed_email' , $allowed_email);
|
||||
$transactionConfig->set('system', 'disallowed_email' , $disallowed_email);
|
||||
$transactionConfig->set('system', 'forbidden_nicknames' , $forbidden_nicknames);
|
||||
$transactionConfig->set('system', 'system_actor_name' , $system_actor_name);
|
||||
$transactionConfig->set('system', 'no_oembed_rich_content' , $no_oembed_rich_content);
|
||||
$transactionConfig->set('system', 'allowed_oembed' , $allowed_oembed);
|
||||
$transactionConfig->set('system', 'block_public' , $block_public);
|
||||
$transactionConfig->set('system', 'publish_all' , $force_publish);
|
||||
$transactionConfig->set('system', 'newuser_private' , $newuser_private);
|
||||
$transactionConfig->set('system', 'enotify_no_content' , $enotify_no_content);
|
||||
$transactionConfig->set('system', 'disable_embedded' , $disable_embedded);
|
||||
$transactionConfig->set('system', 'account_abandon_days', $abandon_days);
|
||||
$transactionConfig->set('config', 'register_text', $register_text);
|
||||
$transactionConfig->set('system', 'allowed_sites', $allowed_sites);
|
||||
$transactionConfig->set('system', 'allowed_email', $allowed_email);
|
||||
$transactionConfig->set('system', 'disallowed_email', $disallowed_email);
|
||||
$transactionConfig->set('system', 'forbidden_nicknames', $forbidden_nicknames);
|
||||
$transactionConfig->set('system', 'system_actor_name', $system_actor_name);
|
||||
$transactionConfig->set('system', 'no_oembed_rich_content', $no_oembed_rich_content);
|
||||
$transactionConfig->set('system', 'allowed_oembed', $allowed_oembed);
|
||||
$transactionConfig->set('system', 'block_public', $block_public);
|
||||
$transactionConfig->set('system', 'publish_all', $force_publish);
|
||||
$transactionConfig->set('system', 'newuser_private', $newuser_private);
|
||||
$transactionConfig->set('system', 'enotify_no_content', $enotify_no_content);
|
||||
$transactionConfig->set('system', 'disable_embedded', $disable_embedded);
|
||||
$transactionConfig->set('system', 'allow_users_remote_self', $allow_users_remote_self);
|
||||
$transactionConfig->set('system', 'allow_relay_channels' , $allow_relay_channels);
|
||||
$transactionConfig->set('system', 'adjust_poll_frequency' , $adjust_poll_frequency);
|
||||
$transactionConfig->set('system', 'min_poll_interval' , $min_poll_interval);
|
||||
$transactionConfig->set('system', 'explicit_content' , $explicit_content);
|
||||
$transactionConfig->set('system', 'local_search' , $local_search);
|
||||
$transactionConfig->set('system', 'blocked_tags' , Strings::cleanTags($blocked_tags));
|
||||
$transactionConfig->set('system', 'cache_contact_avatar' , $cache_contact_avatar);
|
||||
$transactionConfig->set('system', 'check_new_version_url' , $check_new_version_url);
|
||||
$transactionConfig->set('system', 'allow_relay_channels', $allow_relay_channels);
|
||||
$transactionConfig->set('system', 'adjust_poll_frequency', $adjust_poll_frequency);
|
||||
$transactionConfig->set('system', 'min_poll_interval', $min_poll_interval);
|
||||
$transactionConfig->set('system', 'explicit_content', $explicit_content);
|
||||
$transactionConfig->set('system', 'local_search', $local_search);
|
||||
$transactionConfig->set('system', 'blocked_tags', Strings::cleanTags($blocked_tags));
|
||||
$transactionConfig->set('system', 'cache_contact_avatar', $cache_contact_avatar);
|
||||
$transactionConfig->set('system', 'check_new_version_url', $check_new_version_url);
|
||||
|
||||
$transactionConfig->set('system', 'block_extended_register', !$enable_multi_reg);
|
||||
$transactionConfig->set('system', 'no_openid' , !$enable_openid);
|
||||
$transactionConfig->set('system', 'no_regfullname' , !$enable_regfullname);
|
||||
$transactionConfig->set('system', 'register_notification' , $register_notification);
|
||||
$transactionConfig->set('system', 'community_page_style' , $community_page_style);
|
||||
$transactionConfig->set('system', 'no_openid', !$enable_openid);
|
||||
$transactionConfig->set('system', 'no_regfullname', !$enable_regfullname);
|
||||
$transactionConfig->set('system', 'register_notification', $register_notification);
|
||||
$transactionConfig->set('system', 'community_page_style', $community_page_style);
|
||||
$transactionConfig->set('system', 'max_author_posts_community_page', $max_author_posts_community_page);
|
||||
$transactionConfig->set('system', 'max_server_posts_community_page', $max_server_posts_community_page);
|
||||
$transactionConfig->set('system', 'verifyssl' , $verifyssl);
|
||||
$transactionConfig->set('system', 'proxyuser' , $proxyuser);
|
||||
$transactionConfig->set('system', 'proxy' , $proxy);
|
||||
$transactionConfig->set('system', 'curl_timeout' , $timeout);
|
||||
$transactionConfig->set('system', 'imap_disabled' , !$mail_enabled && function_exists('imap_open'));
|
||||
$transactionConfig->set('system', 'diaspora_enabled' , $diaspora_enabled);
|
||||
$transactionConfig->set('system', 'verifyssl', $verifyssl);
|
||||
$transactionConfig->set('system', 'proxyuser', $proxyuser);
|
||||
$transactionConfig->set('system', 'proxy', $proxy);
|
||||
$transactionConfig->set('system', 'curl_timeout', $timeout);
|
||||
$transactionConfig->set('system', 'imap_disabled', !$mail_enabled && function_exists('imap_open'));
|
||||
$transactionConfig->set('system', 'diaspora_enabled', $diaspora_enabled);
|
||||
|
||||
$transactionConfig->set('config', 'private_addons' , $private_addons);
|
||||
$transactionConfig->set('config', 'private_addons', $private_addons);
|
||||
|
||||
$transactionConfig->set('system', 'force_ssl' , $force_ssl);
|
||||
$transactionConfig->set('system', 'hide_help' , !$show_help);
|
||||
$transactionConfig->set('system', 'force_ssl', $force_ssl);
|
||||
$transactionConfig->set('system', 'hide_help', !$show_help);
|
||||
|
||||
$transactionConfig->set('system', 'dbclean' , $dbclean);
|
||||
$transactionConfig->set('system', 'dbclean-expire-days' , $dbclean_expire_days);
|
||||
$transactionConfig->set('system', 'dbclean', $dbclean);
|
||||
$transactionConfig->set('system', 'dbclean-expire-days', $dbclean_expire_days);
|
||||
$transactionConfig->set('system', 'dbclean_expire_conversation', $dbclean_expire_conv);
|
||||
|
||||
if ($dbclean_unclaimed == 0) {
|
||||
|
@ -314,28 +313,28 @@ class Site extends BaseAdmin
|
|||
$transactionConfig->set('system', 'process_view', $process_view);
|
||||
$transactionConfig->set('system', 'archival_days', $archival_days);
|
||||
|
||||
$transactionConfig->set('system', 'worker_queues' , $worker_queues);
|
||||
$transactionConfig->set('system', 'worker_queues', $worker_queues);
|
||||
$transactionConfig->set('system', 'worker_load_cooldown', $worker_load_cooldown);
|
||||
$transactionConfig->set('system', 'worker_fastlane' , $worker_fastlane);
|
||||
$transactionConfig->set('system', 'decoupled_receiver' , $decoupled_receiver);
|
||||
$transactionConfig->set('system', 'cron_interval' , max($cron_interval, 1));
|
||||
$transactionConfig->set('system', 'worker_defer_limit' , $worker_defer_limit);
|
||||
$transactionConfig->set('system', 'worker_fetch_limit' , max($worker_fetch_limit, 1));
|
||||
$transactionConfig->set('system', 'worker_fastlane', $worker_fastlane);
|
||||
$transactionConfig->set('system', 'decoupled_receiver', $decoupled_receiver);
|
||||
$transactionConfig->set('system', 'cron_interval', max($cron_interval, 1));
|
||||
$transactionConfig->set('system', 'worker_defer_limit', $worker_defer_limit);
|
||||
$transactionConfig->set('system', 'worker_fetch_limit', max($worker_fetch_limit, 1));
|
||||
|
||||
$transactionConfig->set('system', 'relay_directly' , $relay_directly);
|
||||
$transactionConfig->set('system', 'relay_scope' , $relay_scope);
|
||||
$transactionConfig->set('system', 'relay_server_tags' , Strings::cleanTags($relay_server_tags));
|
||||
$transactionConfig->set('system', 'relay_deny_tags' , Strings::cleanTags($relay_deny_tags));
|
||||
$transactionConfig->set('system', 'relay_max_tags' , $relay_max_tags);
|
||||
$transactionConfig->set('system', 'relay_user_tags' , $relay_user_tags);
|
||||
$transactionConfig->set('system', 'relay_directly', $relay_directly);
|
||||
$transactionConfig->set('system', 'relay_scope', $relay_scope);
|
||||
$transactionConfig->set('system', 'relay_server_tags', Strings::cleanTags($relay_server_tags));
|
||||
$transactionConfig->set('system', 'relay_deny_tags', Strings::cleanTags($relay_deny_tags));
|
||||
$transactionConfig->set('system', 'relay_max_tags', $relay_max_tags);
|
||||
$transactionConfig->set('system', 'relay_user_tags', $relay_user_tags);
|
||||
$transactionConfig->set('system', 'relay_deny_undetected_language', $relay_deny_undetected_language);
|
||||
$transactionConfig->set('system', 'relay_language_quality' , $relay_language_quality);
|
||||
$transactionConfig->set('system', 'relay_languages' , max($relay_languages, 1));
|
||||
$transactionConfig->set('system', 'relay_language_quality', $relay_language_quality);
|
||||
$transactionConfig->set('system', 'relay_languages', max($relay_languages, 1));
|
||||
|
||||
$transactionConfig->set('channel', 'engagement_hours' , $engagement_hours);
|
||||
$transactionConfig->set('channel', 'engagement_post_limit' , $engagement_post_limit);
|
||||
$transactionConfig->set('channel', 'interaction_score_days' , $interaction_score_days);
|
||||
$transactionConfig->set('channel', 'max_posts_per_author' , $max_posts_per_author);
|
||||
$transactionConfig->set('channel', 'engagement_hours', $engagement_hours);
|
||||
$transactionConfig->set('channel', 'engagement_post_limit', $engagement_post_limit);
|
||||
$transactionConfig->set('channel', 'interaction_score_days', $interaction_score_days);
|
||||
$transactionConfig->set('channel', 'max_posts_per_author', $max_posts_per_author);
|
||||
$transactionConfig->set('channel', 'sharer_interaction_days', $sharer_interaction_days);
|
||||
|
||||
$transactionConfig->commit();
|
||||
|
@ -515,7 +514,7 @@ class Site extends BaseAdmin
|
|||
'$local_search' => ['local_search', DI::l10n()->t('Only local search'), DI::config()->get('system', 'local_search'), DI::l10n()->t('Blocks search for users who are not logged in to prevent crawlers from blocking your system.')],
|
||||
'$blocked_tags' => ['blocked_tags', DI::l10n()->t('Blocked tags for trending tags'), DI::config()->get('system', 'blocked_tags'), DI::l10n()->t("Comma separated list of hashtags that shouldn't be displayed in the trending tags.")],
|
||||
'$cache_contact_avatar' => ['cache_contact_avatar', DI::l10n()->t('Cache contact avatars'), DI::config()->get('system', 'cache_contact_avatar'), DI::l10n()->t('Locally store the avatar pictures of the contacts. This uses a lot of storage space but it increases the performance.')],
|
||||
'$allow_users_remote_self'=> ['allow_users_remote_self', DI::l10n()->t('Allow Users to set remote_self'), DI::config()->get('system', 'allow_users_remote_self'), DI::l10n()->t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
|
||||
'$allow_users_remote_self' => ['allow_users_remote_self', DI::l10n()->t('Allow Users to set remote_self'), DI::config()->get('system', 'allow_users_remote_self'), DI::l10n()->t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
|
||||
'$allow_relay_channels' => ['allow_relay_channels', DI::l10n()->t('Allow Users to set up relay channels'), DI::config()->get('system', 'allow_relay_channels'), DI::l10n()->t('If enabled, it is possible to create relay users that are used to reshare content based on user defined channels.')],
|
||||
'$adjust_poll_frequency' => ['adjust_poll_frequency', DI::l10n()->t('Adjust the feed poll frequency'), DI::config()->get('system', 'adjust_poll_frequency'), DI::l10n()->t('Automatically detect and set the best feed poll frequency.')],
|
||||
'$min_poll_interval' => ['min_poll_interval', DI::l10n()->t('Minimum poll interval'), DI::config()->get('system', 'min_poll_interval'), DI::l10n()->t('Minimal distance in minutes between two polls for mail and feed contacts. Reasonable values are between 1 and 59.')],
|
||||
|
@ -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>',
|
||||
$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_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.')],
|
||||
|
||||
'$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;
|
||||
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
class UpdateContact
|
||||
{
|
||||
|
@ -54,4 +56,38 @@ class UpdateContact
|
|||
DI::logger()->debug('Update contact', ['id' => $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.
|
||||
'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)
|
||||
// The fully-qualified URL of this Friendica node.
|
||||
// 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>
|
||||
{{include file="field_select.tpl" field=$contact_discovery}}
|
||||
{{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=$poco_discovery}}
|
||||
{{include file="field_input.tpl" field=$poco_requery_days}}
|
||||
|
|
|
@ -228,6 +228,7 @@
|
|||
<div class="panel-body">
|
||||
{{include file="field_select.tpl" field=$contact_discovery}}
|
||||
{{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=$poco_discovery}}
|
||||
{{include file="field_input.tpl" field=$poco_requery_days}}
|
||||
|
|
Loading…
Add table
Reference in a new issue