]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activityobject.php
Faster NodeInfo stats
[quix0rs-gnu-social.git] / lib / activityobject.php
index 87eea13727e3261c8829a8459dad19b42113caab..597792ffdeb2528852dd7a8e76b21c6928b01e51 100644 (file)
@@ -28,9 +28,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 require_once(INSTALLDIR.'/lib/activitystreamjsondocument.php');
 
@@ -102,6 +100,7 @@ class ActivityObject
     public $content;
     public $owner;
     public $link;
+    public $selfLink;   // think APP (Atom Publishing Protocol)
     public $source;
     public $avatarLinks = array();
     public $geopoint;
@@ -263,12 +262,29 @@ class ActivityObject
         $this->source  = $this->_getSource($element);
 
         $this->link = ActivityUtils::getPermalink($element);
+        $this->selfLink = ActivityUtils::getSelfLink($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;
         }
+
+        $els = $element->childNodes;
+        $out = array();
+
+        for ($i = 0; $i < $els->length; $i++) {
+            $link = $els->item($i);
+            if ($link->localName == ActivityUtils::LINK && $link->namespaceURI == ActivityUtils::ATOM) {
+                $attrs = array();
+                foreach ($link->attributes as $attrName=>$attrNode) {
+                    $attrs[$attrName] = $attrNode->nodeValue;
+                }
+                $this->extra[] = [$link->localName,
+                                    $attrs,
+                                    $link->nodeValue];
+            }
+        }
     }
 
     // @todo FIXME: rationalize with Activity::_fromRssItem()
@@ -491,7 +507,7 @@ class ActivityObject
 
             $object->type = self::mimeTypeToObjectType($file->mimetype);
             $object->id   = TagURI::mint(sprintf("file:%d", $file->id));
-            $object->link = common_local_url('attachment', array('attachment' => $file->id));
+            $object->link = $file->getAttachmentUrl();
 
             if ($file->title) {
                 $object->title = $file->title;
@@ -651,6 +667,18 @@ class ActivityObject
                 );
             }
 
+            if (!empty($this->selfLink)) {
+                $xo->element(
+                    'link',
+                    array(
+                        'rel' => 'self',
+                        'type' => 'application/atom+xml',
+                        'href' => $this->selfLink
+                    ),
+                    null
+                );
+            }
+
             if(!empty($this->owner)) {
                 $owner = $this->owner->asActivityNoun(self::AUTHOR);
                 $xo->raw($owner);