Allow the search for contacts on blocked servers via web
This commit is contained in:
parent
e6ce165bb5
commit
f0743e4e12
4 changed files with 15 additions and 11 deletions
|
@ -171,7 +171,7 @@ class Search
|
|||
{
|
||||
Logger::info('Searching', ['search' => $search, 'type' => $type, 'start' => $start, 'itempage' => $itemPage]);
|
||||
|
||||
$contacts = Contact::searchByName($search, $type == self::TYPE_FORUM ? 'community' : '');
|
||||
$contacts = Contact::searchByName($search, $type == self::TYPE_FORUM ? 'community' : '', true);
|
||||
|
||||
$resultList = new ResultList($start, $itemPage, count($contacts));
|
||||
|
||||
|
@ -226,7 +226,7 @@ class Search
|
|||
|
||||
// check if searching in the local global contact table is enabled
|
||||
if (DI::config()->get('system', 'poco_local_search')) {
|
||||
$return = Contact::searchByName($search, $mode);
|
||||
$return = Contact::searchByName($search, $mode, true);
|
||||
} else {
|
||||
$p = $page > 1 ? 'p=' . $page : '';
|
||||
$curlResult = DI::httpClient()->get(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), HttpClientAccept::JSON);
|
||||
|
|
|
@ -3506,6 +3506,7 @@ class Contact
|
|||
*
|
||||
* @param string $search Name or nick
|
||||
* @param string $mode Search mode (e.g. "community")
|
||||
* @param bool $show_blocked Show users from blocked servers. Default is false
|
||||
* @param int $uid User ID
|
||||
* @param int $limit Maximum amount of returned values
|
||||
* @param int $offset Limit offset
|
||||
|
@ -3513,7 +3514,7 @@ class Contact
|
|||
* @return array with search results
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function searchByName(string $search, string $mode = '', int $uid = 0, int $limit = 0, int $offset = 0): array
|
||||
public static function searchByName(string $search, string $mode = '', bool $show_blocked = false, int $uid = 0, int $limit = 0, int $offset = 0): array
|
||||
{
|
||||
if (empty($search)) {
|
||||
return [];
|
||||
|
@ -3532,13 +3533,16 @@ class Contact
|
|||
$condition = [
|
||||
'network' => $networks,
|
||||
'server-failed' => false,
|
||||
'server-blocked' => false,
|
||||
'failed' => false,
|
||||
'deleted' => false,
|
||||
'unsearchable' => false,
|
||||
'uid' => $uid
|
||||
];
|
||||
|
||||
if (!$show_blocked) {
|
||||
$condition['server-blocked'] = true;
|
||||
}
|
||||
|
||||
if ($uid == 0) {
|
||||
$condition['blocked'] = false;
|
||||
} else {
|
||||
|
|
|
@ -60,7 +60,7 @@ class Search extends BaseApi
|
|||
}
|
||||
|
||||
if (empty($accounts)) {
|
||||
$contacts = Contact::searchByName($request['q'], '', $request['following'] ? $uid : 0, $request['limit'], $request['offset']);
|
||||
$contacts = Contact::searchByName($request['q'], '', false, $request['following'] ? $uid : 0, $request['limit'], $request['offset']);
|
||||
foreach ($contacts as $contact) {
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($contact['id'], $uid);
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ class Search extends BaseApi
|
|||
}
|
||||
|
||||
$accounts = [];
|
||||
foreach (Contact::searchByName($q, '', $following ? $uid : 0, $limit, $offset) as $contact) {
|
||||
foreach (Contact::searchByName($q, '', $following ? $uid : 0, false, $limit, $offset) as $contact) {
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($contact['id'], $uid);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue