]> git.mxchange.org Git - friendica.git/commitdiff
Use central function to fetch the global directory
authorMichael <heluecht@pirati.ca>
Tue, 26 Apr 2022 18:33:58 +0000 (18:33 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 26 Apr 2022 18:33:58 +0000 (18:33 +0000)
13 files changed:
src/Content/Widget.php
src/Core/Search.php
src/Model/Contact.php
src/Model/User.php
src/Module/Api/Friendica/Profile/Show.php
src/Module/Api/Mastodon/Accounts/Search.php
src/Module/Api/Mastodon/Search.php
src/Module/BaseSearch.php
src/Module/Directory.php
src/Module/Invite.php
src/Module/Settings/Account.php
src/Worker/Directory.php
src/Worker/PullDirectory.php

index 86339928702dadadd879f02e1dbef365d6785d8d..1b2502d2d65e08a66de4110ca9f3cbf3acba23fd 100644 (file)
@@ -25,12 +25,14 @@ use Friendica\Core\Addon;
 use Friendica\Core\Cache\Enum\Duration;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Group;
 use Friendica\Model\Item;
 use Friendica\Model\Post;
+use Friendica\Model\Profile;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Temporal;
 
@@ -59,7 +61,7 @@ class Widget
         */
        public static function findPeople()
        {
-               $global_dir = DI::config()->get('system', 'directory');
+               $global_dir = Search::getGlobalDirectory();
 
                if (DI::config()->get('system', 'invitation_only')) {
                        $x = intval(DI::pConfig()->get(local_user(), 'system', 'invites_remaining'));
@@ -81,7 +83,7 @@ class Widget
                $nv['random'] = DI::l10n()->t('Random Profile');
                $nv['inv'] = DI::l10n()->t('Invite Friends');
                $nv['directory'] = DI::l10n()->t('Global Directory');
-               $nv['global_dir'] = $global_dir;
+               $nv['global_dir'] = Profile::zrl($global_dir, true);
                $nv['local_directory'] = DI::l10n()->t('Local Directory');
 
                $aside = [];
index 17b9eeb8ffc6296be5311b63ad67958006dba76f..41c75ad32b2b463c47af5d3c89bd5f69c7c9ecbf 100644 (file)
@@ -104,7 +104,7 @@ class Search
         */
        public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1)
        {
-               $server = DI::config()->get('system', 'directory', self::DEFAULT_DIRECTORY);
+               $server = self::getGlobalDirectory();
 
                $searchUrl = $server . '/search';
 
index acb4bc10ed2e95bce7be8030b6813d8727b757d6..2204b6c6e0471f26133998e6ca657cc3f666a8f2 100644 (file)
@@ -2781,6 +2781,7 @@ class Contact
                        self::remove($contact['id']);
                } else {
                        DI::logger()->info('Couldn\'t remove follower because of invalid contact array', ['contact' => $contact, 'callstack' => System::callstack()]);
+                       return;
                }
 
                $cdata = Contact::getPublicAndUserContactID($contact['id'], $contact['uid']);
index 500b63658d5ae9b64ef04e747ca17cd578141f83..71e2c8a81200d2942ad64f62dd642a4146688e6f 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\Core\Hook;
 use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
+use Friendica\Core\Search;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
@@ -1287,7 +1288,7 @@ class User
 
                $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid']]);
 
-               if (DBA::isResult($profile) && $profile['net-publish'] && DI::config()->get('system', 'directory')) {
+               if (DBA::isResult($profile) && $profile['net-publish'] && Search::getGlobalDirectory()) {
                        $url = DI::baseUrl() . '/profile/' . $user['nickname'];
                        Worker::add(PRIORITY_LOW, "Directory", $url);
                }
index 2d686d9cae6940892d5332fbc7ae298eaf5a7938..67f4e22edf308f301ece1e300bfab997b10044b2 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module\Api\Friendica\Profile;
 
 use Friendica\Profile\ProfileField\Collection\ProfileFields;
 use Friendica\Content\Text\BBCode;
+use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model\Profile;
 use Friendica\Module\BaseApi;
@@ -39,7 +40,7 @@ class Show extends BaseApi
                $uid = self::getCurrentUserID();
 
                // retrieve general information about profiles for user
-               $directory = DI::config()->get('system', 'directory');
+               $directory = Search::getGlobalDirectory();
 
                $profile = Profile::getByUID($uid);
                
index cec6cc0d95f44a6532884999d310e69987d5cfc3..60db5b057d03b756d356924d6c62d122338dc3f7 100644 (file)
@@ -59,7 +59,7 @@ class Search extends BaseApi
                        if (empty($results)) {
                                if (DI::config()->get('system', 'poco_local_search')) {
                                        $results = CoreSearch::getContactsFromLocalDirectory($request['q'], CoreSearch::TYPE_ALL, 0, $request['limit']);
-                               } elseif (!empty(DI::config()->get('system', 'directory'))) {
+                               } elseif (CoreSearch::getGlobalDirectory()) {
                                        $results = CoreSearch::getContactsFromGlobalDirectory($request['q'], CoreSearch::TYPE_ALL, 1);
                                }
                        }
index 691594477665310e32620e854ac37363c74aecf8..e3f462325ed54abf9cfb2cb1fe2a20254ee02741 100644 (file)
@@ -91,7 +91,7 @@ class Search extends BaseApi
                        if (empty($results)) {
                                if (DI::config()->get('system', 'poco_local_search')) {
                                        $results = CoreSearch::getContactsFromLocalDirectory($q, CoreSearch::TYPE_ALL, 0, $limit);
-                               } elseif (!empty(DI::config()->get('system', 'directory'))) {
+                               } elseif (CoreSearch::getGlobalDirectory()) {
                                        $results = CoreSearch::getContactsFromGlobalDirectory($q, CoreSearch::TYPE_ALL, 1);
                                }
                        }
index 3abc92318262d8754d8655b36af61dac01e8208e..ca5bb761275688fd927a36774f05ddb3ea0b43af 100644 (file)
@@ -91,7 +91,7 @@ class BaseSearch extends BaseModule
                if ($localSearch && empty($results)) {
                        $pager->setItemsPerPage(80);
                        $results = Search::getContactsFromLocalDirectory($search, $type, $pager->getStart(), $pager->getItemsPerPage());
-               } elseif (strlen($config->get('system', 'directory')) && empty($results)) {
+               } elseif (Search::getGlobalDirectory() && empty($results)) {
                        $results = Search::getContactsFromGlobalDirectory($search, $type, $pager->getPage());
                        $pager->setItemsPerPage($results->getItemsPage());
                }
index 8d7b8611b64e1f03f09cf745f3a37b3a3297d673..b79e7b1495a3c89ac99b60f2e26a6b4938499ed3 100644 (file)
@@ -28,6 +28,7 @@ use Friendica\Content\Widget;
 use Friendica\Core\Hook;
 use Friendica\Core\Session;
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model;
 use Friendica\Model\Profile;
@@ -61,7 +62,7 @@ class Directory extends BaseModule
                $search = trim(rawurldecode($_REQUEST['search'] ?? ''));
 
                $gDirPath = '';
-               $dirURL = $config->get('system', 'directory');
+               $dirURL = Search::getGlobalDirectory();
                if (strlen($dirURL)) {
                        $gDirPath = Profile::zrl($dirURL, true);
                }
index 1ce9700697c6ae7e67b64fa44f1d2dbe9db24028..77a7585bd48f1e37b248ab8d525b054d0fc2d58b 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Module;
 
 use Friendica\BaseModule;
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model;
 use Friendica\Model\User;
@@ -143,7 +144,7 @@ class Invite extends BaseModule
                        }
                }
 
-               $dirLocation = $config->get('system', 'directory');
+               $dirLocation = Search::getGlobalDirectory();
                if (strlen($dirLocation)) {
                        if ($config->get('config', 'register_policy') === Register::CLOSED) {
                                $linkTxt = DI::l10n()->t('Visit %s for a list of public sites that you can join. Friendica members on other sites can all connect with each other, as well as with members of many other social networks.', $dirLocation . '/servers');
index d991fd89ec6be9fc7537c855495d20305c23bc2d..bba8e19413f91567c612cee46fe46cfc199675f8 100644 (file)
@@ -25,6 +25,7 @@ use Exception;
 use Friendica\Core\ACL;
 use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
+use Friendica\Core\Search;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -516,8 +517,8 @@ class Account extends BaseSettings
                }
 
                $net_pub_desc = '';
-               if (strlen(DI::config()->get('system', 'directory'))) {
-                       $net_pub_desc = ' ' . DI::l10n()->t('Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).', DI::config()->get('system', 'directory'), DI::config()->get('system', 'directory'));
+               if (Search::getGlobalDirectory()) {
+                       $net_pub_desc = ' ' . DI::l10n()->t('Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).', Search::getGlobalDirectory(), Search::getGlobalDirectory());
                }
 
                /* Installed langs */
index 65034a44aebe24b19f83570ed4aa9cf6c17a587c..d6294d049893a6049e0deaebd4461cdb2709793a 100644 (file)
@@ -23,6 +23,7 @@ namespace Friendica\Worker;
 
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
+use Friendica\Core\Search;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
@@ -35,7 +36,7 @@ class Directory
 {
        public static function execute($url = '')
        {
-               $dir = DI::config()->get('system', 'directory');
+               $dir = Search::getGlobalDirectory();
 
                if (!strlen($dir)) {
                        return;
index 2cf084124690d93126b8f47a5d4358296c6e1717..8a22e504c0454fa72e89b3c6bdc55a1672ea8d3e 100644 (file)
@@ -22,6 +22,7 @@
 namespace Friendica\Worker;
 
 use Friendica\Core\Logger;
+use Friendica\Core\Search;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Network\HTTPClient\Client\HttpClientAccept;
@@ -38,7 +39,7 @@ class PullDirectory
                        return;
                }
 
-               $directory = DI::config()->get('system', 'directory');
+               $directory = Search::getGlobalDirectory();
                if (empty($directory)) {
                        Logger::info('No directory configured');
                        return;