]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
special-case Posterous author element for activity actor
authorEvan Prodromou <evan@status.net>
Sat, 20 Mar 2010 21:53:30 +0000 (16:53 -0500)
committerEvan Prodromou <evan@status.net>
Sat, 20 Mar 2010 21:53:30 +0000 (16:53 -0500)
lib/activity.php
lib/activityobject.php

index b1744e68f585c681d76cab8097ee7c0b58d558b9..691ace1f6f1e245e19b1f5bb00841a1c44ac6cf1 100644 (file)
@@ -238,17 +238,17 @@ class Activity
             $this->time = strtotime($pubDateEl->textContent);
         }
 
-        $authorEl = $this->_child($item, self::AUTHOR, self::RSS);
-
-        if (!empty($authorEl)) {
+        if ($authorEl = $this->_child($item, self::AUTHOR, self::RSS)) {
             $this->actor = ActivityObject::fromRssAuthor($authorEl);
+        } else if ($dcCreatorEl = $this->_child($item, self::CREATOR, self::DC)) {
+            $this->actor = ActivityObject::fromDcCreator($dcCreatorEl);
+        } else if ($posterousEl = $this->_child($item, ActivityObject::AUTHOR, ActivityObject::POSTEROUS)) {
+            // Special case for Posterous.com
+            $this->actor = ActivityObject::fromPosterousAuthor($posterousEl);
+        } else if (!empty($channel)) {
+            $this->actor = ActivityObject::fromRssChannel($channel);
         } else {
-            $dcCreatorEl = $this->_child($item, self::CREATOR, self::DC);
-            if (!empty($dcCreatorEl)) {
-                $this->actor = ActivityObject::fromDcCreator($dcCreatorEl);
-            } else if (!empty($channel)) {
-                $this->actor = ActivityObject::fromRssChannel($channel);
-            }
+            // No actor!
         }
 
         $this->title = ActivityUtils::childContent($item, ActivityObject::TITLE, self::RSS);
index b1e9071eda73ab238ec668cc2b49a16759bd6e73..18e3e21ddb2bcd9749e276b23cf706fe45c76d8d 100644 (file)
@@ -80,6 +80,13 @@ class ActivityObject
     const URI   = 'uri';
     const EMAIL = 'email';
 
+    const POSTEROUS   = 'http://posterous.com/help/rss/1.0';
+    const AUTHOR      = 'author';
+    const USERIMAGE   = 'userImage';
+    const PROFILEURL  = 'profileUrl';
+    const NICKNAME    = 'nickName';
+    const DISPLAYNAME = 'displayName';
+
     public $element;
     public $type;
     public $id;
@@ -296,6 +303,31 @@ class ActivityObject
         return $obj;
     }
 
+    public static function fromPosterousAuthor($el)
+    {
+        $obj = new ActivityObject();
+
+        $obj->type = ActivityObject::PERSON; // @fixme any others...?
+
+        $userImage = ActivityUtils::childContent($el, self::USERIMAGE, self::POSTEROUS);
+
+        if (!empty($userImage)) {
+            $obj->avatarLinks[] = $userImage;
+        }
+
+        $obj->link = ActivityUtils::childContent($el, self::PROFILEURL, self::POSTEROUS);
+        $obj->id   = $obj->link;
+
+        $obj->poco = new PoCo();
+
+        $obj->poco->preferredUsername = ActivityUtils::childContent($el, self::NICKNAME, self::POSTEROUS);
+        $obj->poco->displayName       = ActivityUtils::childContent($el, self::DISPLAYNAME, self::POSTEROUS);
+
+        $obj->title = $obj->poco->displayName;
+
+        return $obj;
+    }
+
     private function _childContent($element, $tag, $namespace=ActivityUtils::ATOM)
     {
         return ActivityUtils::childContent($element, $tag, $namespace);