Convert Directory Search results into contact-looking records

- Address https://github.com/friendica/friendica/issues/12488#issuecomment-1368216631
This commit is contained in:
Hypolite Petovan 2022-12-31 23:13:50 -05:00
parent 6e06a7f14c
commit f9676c9ed2

View file

@ -233,7 +233,24 @@ class Search
if ($curlResult->isSuccess()) {
$searchResult = json_decode($curlResult->getBody(), true);
if (!empty($searchResult['profiles'])) {
$return = $searchResult['profiles'];
// Converting Directory Search results into contact-looking records
$return = array_map(function ($result) {
static $contactType = [
'People' => Contact::TYPE_PERSON,
'Forum' => Contact::TYPE_COMMUNITY,
'Organization' => Contact::TYPE_ORGANISATION,
'News' => Contact::TYPE_NEWS,
];
return [
'name' => $result['name'],
'addr' => $result['addr'],
'url' => $result['profile_url'],
'network' => Protocol::DFRN,
'micro' => $result['photo'],
'contact-type' => $contactType[$result['account_type']],
];
}, $searchResult['profiles']);
}
}
}