mirror of
https://github.com/friendica/friendica
synced 2025-04-29 23:44:22 +02:00
Add SessionUsers class including tests
This commit is contained in:
parent
66a4c30eb7
commit
940619325d
9 changed files with 542 additions and 5 deletions
|
@ -261,6 +261,32 @@ class Contact
|
|||
return DBA::selectFirst('contact', $fields, ['uri-id' => $uri_id], ['order' => ['uid']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all remote contacts for a given contact url
|
||||
*
|
||||
* @param string $url The URL of the contact
|
||||
* @param array $fields The wanted fields
|
||||
*
|
||||
* @return array all remote contacts
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function getVisitorByUrl(string $url, array $fields = ['id', 'uid']): array
|
||||
{
|
||||
$remote = [];
|
||||
|
||||
$remote_contacts = DBA::select('contact', ['id', 'uid'], ['nurl' => Strings::normaliseLink($url), 'rel' => [Contact::FOLLOWER, Contact::FRIEND], 'self' => false]);
|
||||
while ($contact = DBA::fetch($remote_contacts)) {
|
||||
if (($contact['uid'] == 0) || Contact\User::isBlocked($contact['id'], $contact['uid'])) {
|
||||
continue;
|
||||
}
|
||||
$remote[$contact['uid']] = $contact['id'];
|
||||
}
|
||||
DBA::close($remote_contacts);
|
||||
|
||||
return $remote;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a contact by a given url
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue