]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelinehome.php
OAuth related syntax fixes, nothing big
[quix0rs-gnu-social.git] / actions / apitimelinehome.php
index 023c9698a1d9fbf45910793e4edf1cb18b8a1896..7ef3da79f0de65c11471623fd693d392c5dcfd31 100644 (file)
@@ -38,8 +38,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns the most recent notices (default 20) posted by the target user.
  * This is the equivalent of 'You and friends' page accessed via Web.
@@ -107,7 +105,6 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
     function showTimeline()
     {
         $profile    = $this->user->getProfile();
-        $avatar     = $profile->getAvatar(AVATAR_PROFILE_SIZE);
         $sitename   = common_config('site', 'name');
         // TRANS: Timeline title for user and friends. %s is a user nickname.
         $title      = sprintf(_("%s and friends"), $this->user->nickname);
@@ -120,17 +117,11 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
             $this->user->nickname, $sitename
         );
 
-        $link = common_local_url(
-            'all',
-            array('nickname' => $this->user->nickname)
-        );
-
+        $logo = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
+        $link = common_local_url('all',
+                    array('nickname' => $this->user->nickname));
         $self = $this->getSelfUri();
 
-        $logo = (!empty($avatar))
-            ? $avatar->displayUrl()
-            : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
-
         switch($this->format) {
         case 'xml':
             $this->showXmlTimeline($this->notices);
@@ -169,7 +160,7 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
             $this->showJsonTimeline($this->notices);
             break;
         case 'as':
-            header('Content-Type: application/json; charset=utf-8');
+            header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
             $doc = new ActivityStreamJSONDocument($this->auth_user);
             $doc->setTitle($title);
             $doc->addLink($link, 'alternate', 'text/html');
@@ -177,7 +168,7 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
             $this->raw($doc->asString());
             break;
         default:
-            // TRANS: Client error displayed when trying to handle an unknown API method.
+            // TRANS: Client error displayed when coming across a non-supported API method.
             $this->clientError(_('API method not found.'), $code = 404);
             break;
         }
@@ -192,20 +183,19 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
     {
         $notices = array();
 
-        if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
-            $notice = $this->user->noticeInbox(
-                ($this->page-1) * $this->count,
-                $this->count, $this->since_id,
-                $this->max_id
-            );
-        } else {
-            $notice = $this->user->noticesWithFriends(
-                ($this->page-1) * $this->count,
-                $this->count, $this->since_id,
-                $this->max_id
-            );
+        $profile = null;
+
+        if (isset($this->auth_user)) {
+            $profile = $this->auth_user->getProfile();
         }
 
+        $stream = new InboxNoticeStream($this->user, $profile);
+        
+        $notice = $stream->getNotices(($this->page-1) * $this->count,
+                                      $this->count,
+                                      $this->since_id,
+                                      $this->max_id);
+
         while ($notice->fetch()) {
             $notices[] = clone($notice);
         }