X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FSearch.php;h=d187e939550f79e49158991abfe6f51196dba5b5;hb=48baa0be4b662b7c3d2afebad3b78324677fec14;hp=9700c647225882fe308e4be6568babcbc6645778;hpb=0447bb2769648eadd718e3dd9560ce2f480af8d8;p=friendica.git diff --git a/src/Core/Search.php b/src/Core/Search.php index 9700c64722..d187e93955 100644 --- a/src/Core/Search.php +++ b/src/Core/Search.php @@ -2,8 +2,8 @@ namespace Friendica\Core; -use Friendica\BaseObject; use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\GContact; use Friendica\Network\HTTPException; @@ -20,7 +20,7 @@ use Friendica\Util\Strings; * - Search in the local directory * - Search in the global directory */ -class Search extends BaseObject +class Search { const DEFAULT_DIRECTORY = 'https://dir.friendica.social'; @@ -92,8 +92,7 @@ class Search extends BaseObject */ public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1) { - $config = self::getApp()->getConfig(); - $server = $config->get('system', 'directory', self::DEFAULT_DIRECTORY); + $server = DI::config()->get('system', 'directory', self::DEFAULT_DIRECTORY); $searchUrl = $server . '/search'; @@ -158,7 +157,7 @@ class Search extends BaseObject */ public static function getContactsFromLocalDirectory($search, $type = self::TYPE_ALL, $start = 0, $itemPage = 80) { - $config = self::getApp()->getConfig(); + $config = DI::config(); $diaspora = $config->get('system', 'diaspora_enabled') ? Protocol::DIASPORA : Protocol::DFRN; $ostatus = !$config->get('system', 'ostatus_disabled') ? Protocol::OSTATUS : Protocol::DFRN; @@ -206,10 +205,6 @@ class Search extends BaseObject } while ($row = DBA::fetch($data)) { - if (PortableContact::alternateOStatusUrl($row["nurl"])) { - continue; - } - $urlParts = parse_url($row["nurl"]); // Ignore results that look strange. @@ -242,7 +237,7 @@ class Search extends BaseObject DBA::close($data); // Add found profiles from the global directory to the local directory - Worker::add(PRIORITY_LOW, 'DiscoverPoCo', "dirsearch", urlencode($search)); + Worker::add(PRIORITY_LOW, 'SearchDirectory', $search); return $resultList; } @@ -277,7 +272,7 @@ class Search extends BaseObject $return = GContact::searchByName($search, $mode); } else { $p = $page > 1 ? 'p=' . $page : ''; - $curlResult = Network::curl(get_server() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']); + $curlResult = Network::curl(self::getGlobalDirectory() . '/search/people?' . $p . '&q=' . urlencode($search), false, ['accept_content' => 'application/json']); if ($curlResult->isSuccess()) { $searchResult = json_decode($curlResult->getBody(), true); if (!empty($searchResult['profiles'])) { @@ -288,4 +283,14 @@ class Search extends BaseObject return $return ?? []; } + + /** + * Returns the global directory name, used in this node + * + * @return string + */ + public static function getGlobalDirectory() + { + return Config::get('system', 'directory', self::DEFAULT_DIRECTORY); + } }