]> git.mxchange.org Git - friendica.git/commitdiff
Filter contact search by blocked remote domains
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 27 Mar 2023 13:55:39 +0000 (09:55 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Thu, 20 Apr 2023 11:43:17 +0000 (07:43 -0400)
- Add filter explanation

src/Module/BaseSearch.php
view/templates/contact/list.tpl
view/theme/frio/templates/contact/list.tpl

index cc8fab8f7e5619511ad55b9f41f39dbade71e9aa..675deb8fb26abf935d43f3d51ad4ce12277bab62 100644 (file)
@@ -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 <a href="/friendica">About page</a>.',
+                               '%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 <a href="/friendica">About page</a>.',
+                               $filtered) : '',
                        '$contacts' => $entries,
                        '$paginate' => $pager->renderFull($results->getTotal()),
                ]);
index ec77fd521bca5155dd99aaf5600a6ecb09d634a4..b3ed7df7bb4f541d3841891bcf829b4cb2a9e2aa 100644 (file)
@@ -12,3 +12,7 @@
 <div id="view-contact-end"></div>
 
 {{$paginate nofilter}}
+
+{{if $filtered}}
+       <p>{{$filtered nofilter}}</p>
+{{/if}}
index 1925f7ec4dbb12b04224ef3a4c08a85f61ece8b3..1258ded36bba95eda28f5c9e95940e7c2b9da6e6 100644 (file)
@@ -14,4 +14,8 @@ at the suggest page and also at many other places *}}
        <div id="view-contact-end"></div>
 
        {{$paginate nofilter}}
-</div>
\ No newline at end of file
+
+{{if $filtered}}
+       <p>{{$filtered nofilter}}</p>
+{{/if}}
+</div>