]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/classes/Ostatus_profile.php
Merge branch 'testing' of gitorious.org:statusnet/mainline into testing
[quix0rs-gnu-social.git] / plugins / OStatus / classes / Ostatus_profile.php
index a366c1c2cf4b96fe5d7eea042c1358bedc774ca2..4f73fd65be9dcc6cb04792ec105bc2ab44a1afc3 100644 (file)
@@ -1117,11 +1117,20 @@ class Ostatus_profile extends Memcached_DataObject
             $profile->profileurl = $hints['profileurl'];
         }
 
-        // @fixme bio
+        $profile->bio      = self::getActivityObjectBio($object, $hints);
+        $profile->location = self::getActivityObjectLocation($object, $hints);
+        $profile->homepage = self::getActivityObjectHomepage($object, $hints);
+
+        if (!empty($object->geopoint)) {
+            $location = ActivityContext::locationFromPoint($object->geopoint);
+            if (!empty($location)) {
+                $profile->lat = $location->lat;
+                $profile->lon = $location->lon;
+            }
+        }
+
         // @fixme tags/categories
-        // @fixme location?
         // @todo tags from categories
-        // @todo lat/lon/location?
 
         if ($profile->id) {
             common_log(LOG_DEBUG, "Updating OStatus profile $profile->id from remote info $object->id: " . var_export($object, true) . var_export($hints, true));
@@ -1153,6 +1162,62 @@ class Ostatus_profile extends Memcached_DataObject
         }
     }
 
+    protected static function getActivityObjectHomepage($object, $hints=array())
+    {
+        $homepage = null;
+        $poco     = $object->poco;
+
+        if (!empty($poco)) {
+            $url = $poco->getPrimaryURL();
+            if ($url->type == 'homepage') {
+                $homepage = $url->value;
+            }
+        }
+
+        // @todo Try for a another PoCo URL?
+
+        return $homepage;
+    }
+
+    protected static function getActivityObjectLocation($object, $hints=array())
+    {
+        $location = null;
+
+        if (!empty($object->poco)) {
+            if (isset($object->poco->address->formatted)) {
+                $location = $object->poco->address->formatted;
+                if (mb_strlen($location) > 255) {
+                    $location = mb_substr($note, 0, 255 - 3) . ' … ';
+                }
+            }
+        }
+
+        // @todo Try to find location some othe way? Via goerss point?
+
+        return $location;
+    }
+
+    protected static function getActivityObjectBio($object, $hints=array())
+    {
+        $bio  = null;
+
+        if (!empty($object->poco)) {
+            $note = $object->poco->note;
+            if (!empty($note)) {
+                if (mb_strlen($note) > Profile::maxBio()) {
+                    // XXX: truncate ok?
+                    $bio = mb_substr($note, 0, Profile::maxBio() - 3) . ' … ';
+                } else {
+                    $bio = $note;
+                }
+            }
+        }
+
+        // @todo Try to get bio info some other way?
+
+        return $bio;
+    }
+
     protected static function getActivityObjectNickname($object, $hints=array())
     {
         if ($object->poco) {