From 4c81a7ab91c1ffafaf1cabb6393ceb8f6f11af87 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 28 Mar 2023 05:33:14 +0000 Subject: [PATCH] Don't search for contacts on blocked or failed systems --- database.sql | 10 +++++++--- src/Model/Contact.php | 11 +++++++++-- static/dbstructure.config.php | 2 +- static/dbview.config.php | 4 ++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/database.sql b/database.sql index eefd38984..42a6c1f2e 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2023.03-rc (Giant Rhubarb) --- DB_UPDATE_VERSION 1517 +-- DB_UPDATE_VERSION 1518 -- ------------------------------------------ @@ -2849,7 +2849,9 @@ CREATE VIEW `account-view` AS SELECT `apcontact`.`statuses_count` AS `ap-statuses_count`, `gserver`.`site_name` AS `site_name`, `gserver`.`platform` AS `platform`, - `gserver`.`version` AS `version` + `gserver`.`version` AS `version`, + `gserver`.`blocked` AS `server-blocked`, + `gserver`.`failed` AS `server-failed` FROM `contact` LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id` LEFT JOIN `apcontact` ON `apcontact`.`uri-id` = `contact`.`uri-id` @@ -2953,7 +2955,9 @@ CREATE VIEW `account-user-view` AS SELECT `apcontact`.`statuses_count` AS `ap-statuses_count`, `gserver`.`site_name` AS `site_name`, `gserver`.`platform` AS `platform`, - `gserver`.`version` AS `version` + `gserver`.`version` AS `version`, + `gserver`.`blocked` AS `server-blocked`, + `gserver`.`failed` AS `server-failed` FROM `contact` AS `ucontact` INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0 LEFT JOIN `item-uri` ON `item-uri`.`id` = `ucontact`.`uri-id` diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 8792273ee..54689fb62 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -3529,7 +3529,14 @@ class Contact $networks[] = Protocol::OSTATUS; } - $condition = ['network' => $networks, 'failed' => false, 'deleted' => false, 'uid' => $uid]; + $condition = [ + 'network' => $networks, + 'server-failed' => false, + 'server-blocked' => false, + 'failed' => false, + 'deleted' => false, + 'uid' => $uid + ]; if ($uid == 0) { $condition['blocked'] = false; @@ -3556,7 +3563,7 @@ class Contact ["(NOT `unsearchable` OR `nurl` IN (SELECT `nurl` FROM `owner-view` WHERE `publish` OR `net-publish`)) AND (`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)", $search, $search, $search]); - return self::selectToArray([], $condition, $params); + return DBA::selectToArray('account-user-view', [], $condition, $params); } /** diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 9acfbfcf9..ffb66d970 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1517); + define('DB_UPDATE_VERSION', 1518); } return [ diff --git a/static/dbview.config.php b/static/dbview.config.php index 0f2201953..76278c9a2 100644 --- a/static/dbview.config.php +++ b/static/dbview.config.php @@ -1009,6 +1009,8 @@ "site_name" => ["gserver", "site_name"], "platform" => ["gserver", "platform"], "version" => ["gserver", "version"], + "server-blocked" => ["gserver", "blocked"], + "server-failed" => ["gserver", "failed"], ], "query" => "FROM `contact` LEFT JOIN `item-uri` ON `item-uri`.`id` = `contact`.`uri-id` @@ -1111,6 +1113,8 @@ "site_name" => ["gserver", "site_name"], "platform" => ["gserver", "platform"], "version" => ["gserver", "version"], + "server-blocked" => ["gserver", "blocked"], + "server-failed" => ["gserver", "failed"], ], "query" => "FROM `contact` AS `ucontact` INNER JOIN `contact` ON `contact`.`uri-id` = `ucontact`.`uri-id` AND `contact`.`uid` = 0