Don't search for contacts on blocked or failed systems

This commit is contained in:
Michael 2023-03-28 05:33:14 +00:00
parent f61fd93db0
commit 4c81a7ab91
4 changed files with 21 additions and 6 deletions

View file

@ -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`

View file

@ -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);
}
/**

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1517);
define('DB_UPDATE_VERSION', 1518);
}
return [

View file

@ -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