- // If a contact is connected the url is internally changed to 'redir/CID'. We need the pure url to search for
- // the contact. So we strip out the contact id from the internal url and look in the contact table for
- // the real url (nurl)
- if (strpos($contact_url, 'redir/') === 0) {
- $cid = intval(substr($contact_url, 6));
- $remote_contact = Contact::selectFirst(['nurl'], ['id' => $cid]);
+ /* Possible formats for relative URLs that need to be converted to the absolute contact URL:
+ * - contact/redir/123456
+ * - contact/123456/conversations
+ */
+ if (strpos($contact_url, 'contact/') === 0 && preg_match('/(\d+)/', $contact_url, $matches)) {
+ $remote_contact = Contact::selectFirst(['nurl'], ['id' => $matches[1]]);
if (!$contact_url) {
throw new HTTPException\BadRequestException();
}
// Search for contact data
// Look if the local user has got the contact
if (!$contact_url) {
throw new HTTPException\BadRequestException();
}
// Search for contact data
// Look if the local user has got the contact
- if (Session::isAuthenticated()) {
- $contact = Contact::getByURLForUser($contact_url, local_user());
+ if (DI::userSession()->isAuthenticated()) {
+ $contact = Contact::getByURLForUser($contact_url, DI::userSession()->getLocalUserId());
'name' => $contact['name'],
'nick' => $contact['nick'],
'addr' => $contact['addr'] ?: $contact['url'],
'name' => $contact['name'],
'nick' => $contact['nick'],
'addr' => $contact['addr'] ?: $contact['url'],
- 'thumb' => Proxy::proxifyUrl($contact['thumb'], false, Proxy::SIZE_THUMB),
- 'url' => Contact::magicLink($contact['url']),
+ 'thumb' => Contact::getThumb($contact),
+ 'url' => Contact::magicLinkByContact($contact),
'nurl' => $contact['nurl'],
'location' => $contact['location'],
'about' => $contact['about'],
'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']),
'tags' => $contact['keywords'],
'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'],
'nurl' => $contact['nurl'],
'location' => $contact['location'],
'about' => $contact['about'],
'network_link' => Strings::formatNetworkName($contact['network'], $contact['url']),
'tags' => $contact['keywords'],
'bd' => $contact['bd'] <= DBA::NULL_DATE ? '' : $contact['bd'],