diff --git a/src/Core/Search.php b/src/Core/Search.php index 7f05a3a94..45b64eb51 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -29,6 +29,7 @@ use Friendica\Object\Search\ContactResult; use Friendica\Object\Search\ResultList; use Friendica\Util\Network; use Friendica\Util\Strings; +use GuzzleHttp\Psr7\Uri; /** * Specific class to perform searches for different systems. Currently: @@ -76,7 +77,7 @@ class Search $user_data['name'] ?? '', $user_data['addr'] ?? '', ($contactDetails['addr'] ?? '') ?: ($user_data['url'] ?? ''), - $user_data['url'] ?? '', + new Uri($user_data['url'] ?? ''), $user_data['photo'] ?? '', $user_data['network'] ?? '', $contactDetails['cid'] ?? 0, @@ -142,7 +143,7 @@ class Search $profile['name'] ?? '', $profile['addr'] ?? '', ($contactDetails['addr'] ?? '') ?: $profile_url, - $profile_url, + new Uri($profile_url), $profile['photo'] ?? '', Protocol::DFRN, $contactDetails['cid'] ?? 0, @@ -180,7 +181,7 @@ class Search $contact['name'], $contact['addr'], $contact['addr'] ?: $contact['url'], - $contact['url'], + new Uri($contact['url']), $contact['photo'], $contact['network'], 0, diff --git a/src/Module/BaseSearch.php b/src/Module/BaseSearch.php index cc8fab8f7..675deb8fb 100644 --- a/src/Module/BaseSearch.php +++ b/src/Module/BaseSearch.php @@ -97,6 +97,8 @@ class BaseSearch extends BaseModule } elseif (Search::getGlobalDirectory() && empty($results)) { $results = Search::getContactsFromGlobalDirectory($search, $type, $pager->getPage()); $pager->setItemsPerPage($results->getItemsPage()); + } else { + $results = new ResultList(); } return self::printResult($results, $pager, $header); @@ -120,11 +122,17 @@ class BaseSearch extends BaseModule return ''; } + $filtered = 0; + $entries = []; foreach ($results->getResults() as $result) { - // in case the result is a contact result, add a contact-specific entry if ($result instanceof ContactResult) { + if (Network::isUriBlocked($result->getUrl())) { + $filtered++; + continue; + } + $contact = Model\Contact::getByURLForUser($result->getUrl(), DI::userSession()->getLocalUserId()); if (!empty($contact)) { $entries[] = Contact::getContactTemplateVars($contact); @@ -134,7 +142,11 @@ class BaseSearch extends BaseModule $tpl = Renderer::getMarkupTemplate('contact/list.tpl'); return Renderer::replaceMacros($tpl, [ - 'title' => $header, + '$title' => $header, + '$filtered' => $filtered ? DI::l10n()->tt( + '%d result was filtered out because your node blocks the domain it is registered on. You can review the list of domains your node is currently blocking in the About page.', + '%d results were filtered out because your node blocks the domain they are registered on. You can review the list of domains your node is currently blocking in the About page.', + $filtered) : '', '$contacts' => $entries, '$paginate' => $pager->renderFull($results->getTotal()), ]); diff --git a/src/Object/Search/ContactResult.php b/src/Object/Search/ContactResult.php index c2922ea0e..c46b9b6e4 100644 --- a/src/Object/Search/ContactResult.php +++ b/src/Object/Search/ContactResult.php @@ -22,6 +22,7 @@ namespace Friendica\Object\Search; use Friendica\Model\Search; +use Psr\Http\Message\UriInterface; /** * A search result for contact searching @@ -51,7 +52,7 @@ class ContactResult implements IResult */ private $item; /** - * @var string + * @var UriInterface */ private $url; /** @@ -108,9 +109,9 @@ class ContactResult implements IResult } /** - * @return string + * @return UriInterface */ - public function getUrl(): string + public function getUrl(): UriInterface { return $this->url; } @@ -143,14 +144,14 @@ class ContactResult implements IResult * @param string $name * @param string $addr * @param string $item - * @param string $url + * @param UriInterface $url * @param string $photo * @param string $network * @param int $cid * @param int $pCid * @param string $tags */ - public function __construct($name, $addr, $item, $url, $photo, $network, $cid = 0, $pCid = 0, $tags = '') + public function __construct($name, $addr, $item, UriInterface $url, $photo, $network, $cid = 0, $pCid = 0, $tags = '') { $this->name = $name; $this->addr = $addr; diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 934271fe9..3b6a81b60 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2023.03-rc\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-04-18 19:28+0000\n" +"POT-Creation-Date: 2023-04-20 07:48-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -5540,10 +5540,23 @@ msgstr "" msgid "Forum Search - %s" msgstr "" -#: src/Module/BaseSearch.php:119 src/Module/Contact/MatchInterests.php:139 +#: src/Module/BaseSearch.php:121 src/Module/Contact/MatchInterests.php:139 msgid "No matches" msgstr "" +#: src/Module/BaseSearch.php:147 +#, php-format +msgid "" +"%d result was filtered out because your node blocks the domain it is " +"registered on. You can review the list of domains your node is currently " +"blocking in the About page." +msgid_plural "" +"%d results were filtered out because your node blocks the domain they are " +"registered on. You can review the list of domains your node is currently " +"blocking in the About page." +msgstr[0] "" +msgstr[1] "" + #: src/Module/BaseSettings.php:80 msgid "Account" msgstr "" diff --git a/view/templates/contact/list.tpl b/view/templates/contact/list.tpl index ec77fd521..b3ed7df7b 100644 --- a/view/templates/contact/list.tpl +++ b/view/templates/contact/list.tpl @@ -12,3 +12,7 @@
{{$paginate nofilter}} + +{{if $filtered}} +

{{$filtered nofilter}}

+{{/if}} diff --git a/view/theme/frio/templates/contact/list.tpl b/view/theme/frio/templates/contact/list.tpl index 1925f7ec4..1258ded36 100644 --- a/view/theme/frio/templates/contact/list.tpl +++ b/view/theme/frio/templates/contact/list.tpl @@ -14,4 +14,8 @@ at the suggest page and also at many other places *}}
{{$paginate nofilter}} - \ No newline at end of file + +{{if $filtered}} +

{{$filtered nofilter}}

+{{/if}} +