- if (Session::isAuthenticated()) {
- $contact = Contact::getDetailsByURL($contact_nurl, local_user());
- }
-
- // If not then check the global user
- if (!count($contact)) {
- $contact = Contact::getDetailsByURL($contact_nurl);
- }
-
- // Feeds url could have been destroyed through "cleanContactUrl", so we now use the original url
- if (!count($contact) && Session::isAuthenticated()) {
- $contact_nurl = Strings::normaliseLink($contact_url);
- $contact = Contact::getDetailsByURL($contact_nurl, local_user());
- }
-
- if (!count($contact)) {
- $contact_nurl = Strings::normaliseLink($contact_url);
- $contact = Contact::getDetailsByURL($contact_nurl);
+ if (DI::userSession()->isAuthenticated()) {
+ $contact = Contact::getByURLForUser($contact_url, DI::userSession()->getLocalUserId());
+ } else {
+ $contact = Contact::getByURL($contact_url, false);