]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelinementions.php
OAuth related syntax fixes, nothing big
[quix0rs-gnu-social.git] / actions / apitimelinementions.php
index 2857bd41ea3dc3e4933ed8170d4a3a6e3e7b28f0..aff4f318e945cf0ae940cc63e399d422b3696e7d 100644 (file)
@@ -38,8 +38,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apibareauth.php';
-
 /**
  * Returns the most recent (default 20) mentions (status containing @nickname)
  *
@@ -106,7 +104,6 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
     function showTimeline()
     {
         $profile = $this->user->getProfile();
-        $avatar     = $profile->getAvatar(AVATAR_PROFILE_SIZE);
 
         $sitename   = common_config('site', 'name');
         $title      = sprintf(
@@ -117,11 +114,10 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
         );
         $taguribase = TagURI::base();
         $id         = "tag:$taguribase:Mentions:" . $this->user->id;
-        $link       = common_local_url(
-            'replies',
-            array('nickname' => $this->user->nickname)
-        );
 
+        $logo = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
+        $link = common_local_url('replies',
+                    array('nickname' => $this->user->nickname));
         $self = $this->getSelfUri();
 
         $subtitle   = sprintf(
@@ -131,7 +127,6 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
             _('%1$s updates that reply to updates from %2$s / %3$s.'),
             $sitename, $this->user->nickname, $profile->getBestName()
         );
-        $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
 
         switch($this->format) {
         case 'xml':
@@ -170,7 +165,7 @@ class ApiTimelineMentionsAction 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');
@@ -178,7 +173,7 @@ class ApiTimelineMentionsAction 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;
         }
@@ -193,10 +188,18 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
     {
         $notices = array();
 
-        $notice = $this->user->getReplies(
-            ($this->page - 1) * $this->count, $this->count,
-            $this->since_id, $this->max_id
-        );
+        if (empty($this->auth_user)) {
+            $profile = null; 
+        } else {
+            $profile = $this->auth_user->getProfile();
+        }
+
+        $stream = new ReplyNoticeStream($this->user->id, $profile);
+
+        $notice = $stream->getNotices(($this->page - 1) * $this->count,
+                                      $this->count,
+                                      $this->since_id,
+                                      $this->max_id);
 
         while ($notice->fetch()) {
             $notices[] = clone($notice);