]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Take remote profiles into account when looking up canonical profile URIs
[quix0rs-gnu-social.git] / classes / Profile.php
index c79b1d893a30ba018046817d835dfdbdb246a715..5a86619fd24ac7a6f92add9e9bcc52e7a8ce4f00 100644 (file)
@@ -807,15 +807,10 @@ class Profile extends Memcached_DataObject
             null,
             'http://activitystrea.ms/schema/1.0/person'
         );
-        // FIXME: this presupposes a local user -- not necessarily the case
-        // instead use User::uri or Remote_profile::uri or Ostatus_profile::homeuri
         $xs->element(
             'id',
             null,
-            common_local_url(
-                'userbyid',
-                array('id' => $this->id)
-                )
+            $this->getUri()
             );
         $xs->element('title', null, $this->getBestName());
 
@@ -824,6 +819,7 @@ class Profile extends Memcached_DataObject
         $xs->element(
             'link', array(
                 'type' => empty($avatar) ? 'image/png' : $avatar->mediatype,
+                'rel'  => 'avatar',
                 'href' => empty($avatar)
                 ? Avatar::defaultImage(AVATAR_PROFILE_SIZE)
                 : $avatar->displayUrl()
@@ -836,9 +832,21 @@ class Profile extends Memcached_DataObject
         return $xs->getString();
     }
 
-    function getAcctUri()
+    function getUri()
     {
-        return $this->nickname . '@' . common_config('site', 'server');
+        if (Event::handle('GetProfileUri', array($this))) {
+
+            $remote = Remote_profile::staticGet('id', $this->id);
+
+            if (!empty($remote)) {
+                return $remote->uri;
+            } else {
+                return common_local_url(
+                    'userbyid',
+                    array('id' => $this->id)
+                );
+            }
+        }
     }
 
 }