]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Output selfLink from notice asActivity[Object]
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 6 May 2017 10:25:50 +0000 (12:25 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 6 May 2017 10:26:54 +0000 (12:26 +0200)
classes/Notice.php

index 28f85ce3fb098aad2795d21d8d4c2355c4d133df..1dac58032ccc36f7a9494b341a8ca976854d8be3 100644 (file)
@@ -322,6 +322,19 @@ class Notice extends Managed_DataObject
         }
     }
 
+    public function getSelfLink()
+    {
+        if ($this->isLocal()) {
+            return common_local_url('ApiStatusesShow', array('id' => $this->getID(), 'format' => 'atom'));
+        }
+
+        if (!common_valid_http_url($this->self)) {
+            throw new InvalidUrlException($this->url);
+        }
+
+        return $this->self;
+    }
+
     public function getObjectType($canonical=false) {
         if (is_null($this->object_type) || $this->object_type==='') {
             throw new NoObjectTypeException($this);
@@ -2092,9 +2105,12 @@ class Notice extends Managed_DataObject
                 }
             }
 
+            try {
+                $act->selfLink = $this->getSelfLink();
+            } catch (InvalidUrlException $e) {
+                $act->selfLink = null;
+            }
             if ($this->isLocal()) {
-                $act->selfLink = common_local_url('ApiStatusesShow', array('id' => $this->id,
-                                                                           'format' => 'atom'));
                 $act->editLink = $act->selfLink;
             }
 
@@ -2192,6 +2208,11 @@ class Notice extends Managed_DataObject
             $object->title   = sprintf('New %1$s by %2$s', ActivityObject::canonicalType($object->type), $this->getProfile()->getNickname());
             $object->content = $this->getRendered();
             $object->link    = $this->getUrl();
+            try {
+                $object->selfLink = $this->getSelfLink();
+            } catch (InvalidUrlException $e) {
+                $object->selfLink = null;
+            }
 
             $object->extra[] = array('status_net', array('notice_id' => $this->id));