*
* @param string $user The user to search for
*
- * @return ResultList|null
+ * @return ResultList
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
public static function getContactsFromProbe($user)
{
+ $emptyResultList = new ResultList(1, 0, 1);
+
if ((filter_var($user, FILTER_VALIDATE_EMAIL) && Network::isEmailDomainValid($user)) ||
(substr(Strings::normaliseLink($user), 0, 7) == "http://")) {
$user_data = Probe::uri($user);
if (empty($user_data)) {
- return null;
+ return $emptyResultList;
}
- if (!(in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]))) {
- return null;
+ if (!(in_array($user_data["network"], Protocol::FEDERATED))) {
+ return $emptyResultList;
}
$contactDetails = Contact::getDetailsByURL(defaults($user_data, 'url', ''), local_user());
);
return new ResultList(1, 1, 1, [$result]);
-
} else {
- return null;
+ return $emptyResultList;
}
}
* @param int $type specific type of searching
* @param int $page
*
- * @return ResultList|null
+ * @return ResultList
* @throws HTTPException\InternalServerErrorException
*/
public static function getContactsFromGlobalDirectory($search, $type = self::TYPE_ALL, $page = 1)
$searchUrl .= '&page=' . $page;
}
- $red = 0;
- $resultJson = Network::fetchUrl($searchUrl, false, $red, 0, 'application/json');
+ $resultJson = Network::fetchUrl($searchUrl, false, 0, 'application/json');
$results = json_decode($resultJson, true);
$resultList = new ResultList(
defaults($results, 'page', 1),
- defaults($results, 'count', 1),
- defaults($results, 'itemsperpage', 1)
+ defaults($results, 'count', 0),
+ defaults($results, 'itemsperpage', 30)
);
$profiles = defaults($results, 'profiles', []);
* @param int $start
* @param int $itemPage
*
- * @return ResultList|null
+ * @return ResultList
* @throws HTTPException\InternalServerErrorException
*/
public static function getContactsFromLocalDirectory($search, $type = self::TYPE_ALL, $start = 0, $itemPage = 80)
($type === self::TYPE_FORUM),
]);
+ $resultList = new ResultList($start, $itemPage, $count);
+
if (empty($count)) {
- return null;
+ return $resultList;
}
$data = DBA::select('gcontact', ['nurl'], [
]);
if (!DBA::isResult($data)) {
- return null;
+ return $resultList;
}
- $resultList = new ResultList($start, $itemPage, $count);
-
while ($row = DBA::fetch($data)) {
if (PortableContact::alternateOStatusUrl($row["nurl"])) {
continue;