mirror of
https://github.com/friendica/friendica
synced 2025-04-20 06:30:10 +00:00
Issue 2657: Mentions will now be recognized by clients
This commit is contained in:
parent
b9f0985467
commit
56ac879c92
3 changed files with 19 additions and 36 deletions
|
@ -52,27 +52,15 @@ class Search extends BaseApi
|
|||
|
||||
$accounts = [];
|
||||
|
||||
if ($request['resolve']) {
|
||||
if ((strrpos($request['q'], '@') > 0) || Network::isValidHttpUrl($request['q'])) {
|
||||
$results = CoreSearch::getContactsFromProbe($request['q']);
|
||||
}
|
||||
if ((strrpos($request['q'], '@') > 0) || Network::isValidHttpUrl($request['q'])) {
|
||||
$id = Contact::getIdForURL($request['q'], 0, $request['resolve'] ? null : false);
|
||||
|
||||
if (!empty($results)) {
|
||||
$counter = 0;
|
||||
foreach ($results->getResults() as $result) {
|
||||
if (++$counter > $request['limit']) {
|
||||
continue;
|
||||
}
|
||||
if ($result instanceof ContactResult) {
|
||||
$id = Contact::getIdForURL($result->getUrl(), 0, false);
|
||||
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($id, $uid);
|
||||
}
|
||||
}
|
||||
if (!empty($id)) {
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($id, $uid);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($accounts) < $request['limit']) {
|
||||
if (empty($accounts)) {
|
||||
$contacts = Contact::searchByName($request['q'], '', $request['following'] ? $uid : 0, $request['limit']);
|
||||
foreach ($contacts as $contact) {
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($contact['id'], $uid);
|
||||
|
|
|
@ -84,28 +84,16 @@ class Search extends BaseApi
|
|||
{
|
||||
$accounts = [];
|
||||
|
||||
if ($resolve) {
|
||||
if ((strrpos($q, '@') > 0) || Network::isValidHttpUrl($q)) {
|
||||
$results = CoreSearch::getContactsFromProbe($q);
|
||||
}
|
||||
if ((strrpos($q, '@') > 0) || Network::isValidHttpUrl($q)) {
|
||||
$id = Contact::getIdForURL($q, 0, $resolve ? null : false);
|
||||
|
||||
if (!empty($results)) {
|
||||
$counter = 0;
|
||||
foreach ($results->getResults() as $result) {
|
||||
if (++$counter > $limit) {
|
||||
continue;
|
||||
}
|
||||
if ($result instanceof ContactResult) {
|
||||
$id = Contact::getIdForURL($result->getUrl(), 0, false);
|
||||
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($id, $uid);
|
||||
}
|
||||
}
|
||||
if (!empty($id)) {
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($id, $uid);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($accounts) < $limit) {
|
||||
$contacts = Contact::searchByName($q, '', $following ? $uid : 0, $limit - count($accounts), $offset);
|
||||
if (empty($accounts)) {
|
||||
$contacts = Contact::searchByName($q, '', $following ? $uid : 0, $limit, $offset);
|
||||
foreach ($contacts as $contact) {
|
||||
$accounts[] = DI::mstdnAccount()->createFromContactId($contact['id'], $uid);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue