X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Factivitystreamjsondocument.php;h=0466045fef46c059a7e9a65c6bf2a4d47552e88e;hb=4d6b5e70dff54f168d5e38ef53405ab184af4538;hp=6d17075931768e062172820d8f383d0efee9abf7;hpb=d594c83a5a9a9d42fce917b544c28591fcadb1aa;p=quix0rs-gnu-social.git diff --git a/lib/activitystreamjsondocument.php b/lib/activitystreamjsondocument.php index 6d17075931..0466045fef 100644 --- a/lib/activitystreamjsondocument.php +++ b/lib/activitystreamjsondocument.php @@ -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,10 +165,10 @@ 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['count'] = $this->count; + $this->doc['totalItems'] = $this->count; $this->doc['items'] = $this->items; $this->doc['links'] = $this->links; // extension return json_encode(array_filter($this->doc)); // filter out empty elements @@ -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) ); }