diff --git a/mod/poco.php b/mod/poco.php index f1fdc55d7..abe10ee39 100644 --- a/mod/poco.php +++ b/mod/poco.php @@ -110,7 +110,7 @@ function poco_init(App $a) { $totalResults = DBA::count('profile', ['net-publish' => true]); } else { $contacts = q("SELECT count(*) AS `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 - AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`) + AND NOT `failed` AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra", intval($user['uid']), DBA::escape(Protocol::DFRN), @@ -148,7 +148,7 @@ function poco_init(App $a) { } else { Logger::log("Start query for user " . $user['nickname'], Logger::DEBUG); $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 - AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`) + AND NOT `failed` AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra LIMIT %d, %d", intval($user['uid']), DBA::escape(Protocol::DFRN), diff --git a/src/Core/Search.php b/src/Core/Search.php index ea979610e..edc88ffd7 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -180,7 +180,7 @@ class Search $count = DBA::count('gcontact', [ 'NOT `hide` AND `network` IN (?, ?, ?, ?) - AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) + AND NOT `failed` AND (`url` LIKE ? OR `name` LIKE ? OR `location` LIKE ? OR `addr` LIKE ? OR `about` LIKE ? OR `keywords` LIKE ?) AND `community` = ?', @@ -199,7 +199,7 @@ class Search $data = DBA::select('gcontact', ['nurl', 'name', 'addr', 'url', 'photo', 'network', 'keywords'], [ 'NOT `hide` AND `network` IN (?, ?, ?, ?) - AND ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) + AND NOT `failed` AND (`url` LIKE ? OR `name` LIKE ? OR `location` LIKE ? OR `addr` LIKE ? OR `about` LIKE ? OR `keywords` LIKE ?) AND `community` = ?', diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 00867475a..6a3c7da74 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -95,7 +95,7 @@ class GContact $results = DBA::p("SELECT `nurl` FROM `gcontact` WHERE NOT `hide` AND `network` IN (?, ?, ?, ?) AND - ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND + NOT `failed` AND (`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?) $extra_sql GROUP BY `nurl` ORDER BY `nurl` DESC LIMIT 1000", Protocol::DFRN, Protocol::ACTIVITYPUB, $ostatus, $diaspora, $search, $search, $search @@ -274,8 +274,7 @@ class GContact "SELECT count(*) as `total` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND - ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR - (`gcontact`.`updated` >= `gcontact`.`last_failure`)) + NOT `gcontact`.`failed` AND `gcontact`.`nurl` IN (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 and id != %d) ", intval($cid), intval($uid), @@ -338,7 +337,7 @@ class GContact WHERE `glink`.`cid` = %d and `glink`.`uid` = %d AND `contact`.`uid` = %d AND `contact`.`self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`hidden` = 0 AND `contact`.`id` != %d - AND ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) + AND NOT `gcontact`.`failed` $sql_extra LIMIT %d, %d", intval($cid), intval($uid), @@ -397,7 +396,7 @@ class GContact "SELECT count(*) as `total` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` where `glink`.`cid` = %d and `glink`.`uid` = %d AND - ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`))", + NOT `gcontact`.`failed`", intval($cid), intval($uid) ); @@ -425,7 +424,7 @@ class GContact INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = %d WHERE `glink`.`cid` = %d AND `glink`.`uid` = %d AND - ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR (`gcontact`.`updated` >= `gcontact`.`last_failure`)) + NOT `gcontact`.`failed` ORDER BY `gcontact`.`name` ASC LIMIT %d, %d ", intval($uid), intval($cid), @@ -472,7 +471,7 @@ class GContact AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d) AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d) AND `gcontact`.`updated` >= '%s' AND NOT `gcontact`.`hide` - AND `gcontact`.`last_contact` >= `gcontact`.`last_failure` + AND NOT `gcontact`.`failed` AND `gcontact`.`network` IN (%s) GROUP BY `glink`.`gcid` ORDER BY `gcontact`.`updated` DESC,`total` DESC LIMIT %d, %d", intval($uid), @@ -496,7 +495,7 @@ class GContact AND NOT `gcontact`.`name` IN (SELECT `name` FROM `contact` WHERE `uid` = %d) AND NOT `gcontact`.`id` IN (SELECT `gcid` FROM `gcign` WHERE `uid` = %d) AND `gcontact`.`updated` >= '%s' - AND `gcontact`.`last_contact` >= `gcontact`.`last_failure` + AND NOT `gcontact`.`failed` AND `gcontact`.`network` IN (%s) ORDER BY rand() LIMIT %d, %d", intval($uid), @@ -1270,7 +1269,7 @@ class GContact $r = DBA::select('gserver', ['nurl', 'url'], [ '`network` = ? - AND `last_contact` >= `last_failure` + AND NOT `failed` AND `last_poco_query` < ?', Protocol::OSTATUS, $last_update @@ -1421,8 +1420,8 @@ class GContact public static function getRandomUrl() { $r = DBA::selectFirst('gcontact', ['url'], [ - '`network` = ? - AND `last_contact` >= `last_failure` + '`network` = ? + AND NOT `failed` AND `updated` > ?', Protocol::DFRN, DateTimeFormat::utc('now - 1 month'), diff --git a/src/Model/GServer.php b/src/Model/GServer.php index 23056906c..3d268c37b 100644 --- a/src/Model/GServer.php +++ b/src/Model/GServer.php @@ -1587,7 +1587,7 @@ class GServer $gservers = DBA::p("SELECT `id`, `url`, `nurl`, `network`, `poco` FROM `gserver` - WHERE `last_contact` >= `last_failure` + WHERE NOT `failed` AND `poco` != '' AND `last_poco_query` < ? ORDER BY RAND()", $last_update diff --git a/src/Module/Admin/Federation.php b/src/Module/Admin/Federation.php index 928a286b1..fd60b0715 100644 --- a/src/Module/Admin/Federation.php +++ b/src/Module/Admin/Federation.php @@ -64,14 +64,14 @@ class Federation extends BaseAdmin $gservers = DBA::p("SELECT COUNT(*) AS `total`, SUM(`registered-users`) AS `users`, `platform`, ANY_VALUE(`network`) AS `network`, MAX(`version`) AS `version` - FROM `gserver` WHERE `last_contact` >= `last_failure` GROUP BY `platform`"); + FROM `gserver` WHERE NOT `failed` GROUP BY `platform`"); while ($gserver = DBA::fetch($gservers)) { $total += $gserver['total']; $users += $gserver['users']; $versionCounts = []; $versions = DBA::p("SELECT COUNT(*) AS `total`, `version` FROM `gserver` - WHERE `last_contact` >= `last_failure` AND `platform` = ? + WHERE NOT `failed` AND `platform` = ? GROUP BY `version` ORDER BY `version`", $gserver['platform']); while ($version = DBA::fetch($versions)) { $version['version'] = str_replace(["\n", "\r", "\t"], " ", $version['version']); diff --git a/src/Module/Api/Mastodon/Instance/Peers.php b/src/Module/Api/Mastodon/Instance/Peers.php index 82f08cbad..537d25e28 100644 --- a/src/Module/Api/Mastodon/Instance/Peers.php +++ b/src/Module/Api/Mastodon/Instance/Peers.php @@ -42,7 +42,7 @@ class Peers extends BaseApi $return = []; // We only select for Friendica and ActivityPub servers, since it is expected to only deliver AP compatible systems here. - $instances = DBA::select('gserver', ['url'], ["`network` in (?, ?) AND `last_contact` >= `last_failure`", Protocol::DFRN, Protocol::ACTIVITYPUB]); + $instances = DBA::select('gserver', ['url'], ["`network` in (?, ?) AND NOT `failed`", Protocol::DFRN, Protocol::ACTIVITYPUB]); while ($instance = DBA::fetch($instances)) { $urldata = parse_url($instance['url']); unset($urldata['scheme']); diff --git a/src/Object/Api/Mastodon/Stats.php b/src/Object/Api/Mastodon/Stats.php index 8677cf042..6ead52672 100644 --- a/src/Object/Api/Mastodon/Stats.php +++ b/src/Object/Api/Mastodon/Stats.php @@ -51,7 +51,7 @@ class Stats extends BaseEntity if (!empty(DI::config()->get('system', 'nodeinfo'))) { $stats->user_count = intval(DI::config()->get('nodeinfo', 'total_users')); $stats->status_count = DI::config()->get('nodeinfo', 'local_posts') + DI::config()->get('nodeinfo', 'local_comments'); - $stats->domain_count = DBA::count('gserver', ["`network` in (?, ?) AND `last_contact` >= `last_failure`", Protocol::DFRN, Protocol::ACTIVITYPUB]); + $stats->domain_count = DBA::count('gserver', ["`network` in (?, ?) AND NOT `failed`", Protocol::DFRN, Protocol::ACTIVITYPUB]); } return $stats; } diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index f255347c1..d66676cac 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -228,7 +228,7 @@ class PortableContact { $r = q( "SELECT `url`, `site_name` AS `displayName`, `network`, `platform`, `version` FROM `gserver` - WHERE `network` IN ('%s', '%s', '%s') AND `last_contact` > `last_failure` + WHERE `network` IN ('%s', '%s', '%s') AND NOT `failed` ORDER BY `last_contact` LIMIT 1000", DBA::escape(Protocol::DFRN), diff --git a/src/Worker/SearchDirectory.php b/src/Worker/SearchDirectory.php index 2ffe6120e..afe54e5fb 100644 --- a/src/Worker/SearchDirectory.php +++ b/src/Worker/SearchDirectory.php @@ -58,12 +58,11 @@ class SearchDirectory if (!empty($j->results)) { foreach ($j->results as $jj) { // Check if the contact already exists - $gcontact = DBA::selectFirst('gcontact', ['id', 'last_contact', 'last_failure', 'updated'], ['nurl' => Strings::normaliseLink($jj->url)]); + $gcontact = DBA::selectFirst('gcontact', ['failed'], ['nurl' => Strings::normaliseLink($jj->url)]); if (DBA::isResult($gcontact)) { Logger::info('Profile already exists', ['profile' => $jj->url, 'search' => $search]); - if (($gcontact['last_contact'] < $gcontact['last_failure']) && - ($gcontact['updated'] < $gcontact['last_failure'])) { + if ($gcontact['failed']) { continue; }