]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
move check for bad IDs from activityobject to activity and make simpler
authorEvan Prodromou <evan@status.net>
Sun, 28 Mar 2010 02:44:10 +0000 (22:44 -0400)
committerEvan Prodromou <evan@status.net>
Sun, 28 Mar 2010 02:44:10 +0000 (22:44 -0400)
lib/activity.php
lib/activityobject.php

index f9192c6b80061d4c5caeddfc07f16083e0ab7135..5d6230c6df623ac9000d76aa92d6d9dac1929622 100644 (file)
@@ -179,6 +179,17 @@ class Activity
 
             $this->actor = new ActivityObject($actorEl);
 
+            // Cliqset has bad actor IDs (just nickname of user). We
+            // work around it by getting the author data and using its
+            // id instead
+
+            if (!preg_match('/^\w+:/', $this->actor->id)) {
+                $authorEl = ActivityUtils::child($entry, 'author');
+                if (!empty($authorEl)) {
+                    $authorObj = new ActivityObject($authorEl);
+                    $this->actor->id = $authorObj->id;
+                }
+            }
         } else if (!empty($feed) &&
                    $subjectEl = $this->_child($feed, self::SUBJECT)) {
 
index 34d1b91700432bd1d55dabd041176f0ac2a62e15..677a48197fd9e0e6ff10ee0a14b4e532109c8f7c 100644 (file)
@@ -177,10 +177,7 @@ class ActivityObject
         $this->type  = self::PERSON; // XXX: is this fair?
         $this->title = $this->_childContent($element, self::NAME);
 
-        $id = $this->_childContent($element, self::URI);
-        if (ActivityUtils::validateUri($id)) {
-            $this->id = $id;
-        }
+        $this->id = $this->_childContent($element, self::URI);
 
         if (empty($this->id)) {
             $email = $this->_childContent($element, self::EMAIL);
@@ -193,15 +190,6 @@ class ActivityObject
 
     private function _fromAtomEntry($element)
     {
-        if ($element->localName == 'actor') {
-            // Old-fashioned <activity:actor>...
-            // First pull anything from <author>, then we'll add on top.
-            $author = ActivityUtils::child($element->parentNode, 'author');
-            if ($author) {
-                $this->_fromAuthor($author);
-            }
-        }
-
         $this->type = $this->_childContent($element, Activity::OBJECTTYPE,
                                            Activity::SPEC);
 
@@ -209,11 +197,6 @@ class ActivityObject
             $this->type = ActivityObject::NOTE;
         }
 
-        $id = $this->_childContent($element, self::ID);
-        if (ActivityUtils::validateUri($id)) {
-            $this->id = $id;
-        }
-
         $this->summary = ActivityUtils::childHtmlContent($element, self::SUMMARY);
         $this->content = ActivityUtils::getContent($element);
 
@@ -226,6 +209,12 @@ class ActivityObject
         $this->source  = $this->_getSource($element);
 
         $this->link = ActivityUtils::getPermalink($element);
+
+        $this->id = $this->_childContent($element, self::ID);
+
+        if (empty($this->id) && !empty($this->link)) { // fallback if there's no ID
+            $this->id = $this->link;
+        }
     }
 
     // @fixme rationalize with Activity::_fromRssItem()