]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/activitystreamjsondocument.php
Merge branch 'master' into social-master
[quix0rs-gnu-social.git] / lib / activitystreamjsondocument.php
index c67fc5a42f159ecfc485975256fbfbfd0faaafd6..0466045fef46c059a7e9a65c6bf2a4d47552e88e 100644 (file)
@@ -54,6 +54,7 @@ class ActivityStreamJSONDocument extends JSONActivityCollection
 
     /* The current authenticated user */
     protected $cur;
+    protected $scoped = null;
 
     /* Title of the document */
     protected $title;
@@ -75,7 +76,8 @@ class ActivityStreamJSONDocument extends JSONActivityCollection
     {
         parent::__construct($items, $url);
 
-        $this->cur = $cur;
+        $this->cur = $cur ?: common_current_user();
+        $this->scoped = !is_null($this->cur) ? $this->cur->getProfile() : null;
 
         /* Title of the JSON document */
         $this->title = $title;
@@ -138,10 +140,8 @@ class ActivityStreamJSONDocument extends JSONActivityCollection
 
     function addItemFromNotice($notice)
     {
-        $cur = empty($this->cur) ? common_current_user() : $this->cur;
-
-        $act          = $notice->asActivity($cur);
-        $act->extra[] = $notice->noticeInfo($cur);
+        $act          = $notice->asActivity($this->scoped);
+        $act->extra[] = $notice->noticeInfo($this->scoped);
         array_push($this->items, $act->asArray());
         $this->count++;
     }
@@ -165,7 +165,7 @@ class ActivityStreamJSONDocument extends JSONActivityCollection
      */
     function asString()
     {
-        $this->doc['generator'] = 'StatusNet ' . STATUSNET_VERSION; // extension
+        $this->doc['generator'] = 'GNU social ' . GNUSOCIAL_VERSION; // extension
         $this->doc['title'] = $this->title;
         $this->doc['url']   = $this->url;
         $this->doc['totalItems'] = $this->count;
@@ -201,9 +201,9 @@ class ActivityStreamsMediaLink extends ActivityStreamsLink
     {
         parent::__construct($url, $rel, $mediaType);
         $this->linkDict = array(
-            'width'      => $width,
-            'height'     => $height,
-            'duration'   => $duration
+            'width'      => intval($width),
+            'height'     => intval($height),
+            'duration'   => intval($duration)
         );
     }