]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelinefriends.php
Fix for "#foo !foo" in same notice failing during save, causing failout before distri...
[quix0rs-gnu-social.git] / actions / apitimelinefriends.php
index 9ec7447e64d317593c87d5bb81a083e5ceaf29bc..ac350ab1b7a25acf8c5ee77dba5cd6269089670c 100644 (file)
@@ -72,7 +72,6 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
     function prepare($args)
     {
         parent::prepare($args);
-        common_debug("api friends_timeline");
         $this->user = $this->getTargetUser($this->arg('id'));
 
         if (empty($this->user)) {
@@ -113,47 +112,66 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
         $avatar     = $profile->getAvatar(AVATAR_PROFILE_SIZE);
         $sitename   = common_config('site', 'name');
         $title      = sprintf(_("%s and friends"), $this->user->nickname);
-        $taguribase = common_config('integration', 'taguri');
+        $taguribase = TagURI::base();
         $id         = "tag:$taguribase:FriendsTimeline:" . $this->user->id;
-        $link       = common_local_url(
-                                       'all', array('nickname' => $this->user->nickname)
-                                       );
-        $subtitle   = sprintf(
-                              _('Updates from %1$s and friends on %2$s!'),
-                              $this->user->nickname, $sitename
-                              );
-        $logo       = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
+
+        $subtitle = sprintf(
+            _('Updates from %1$s and friends on %2$s!'),
+            $this->user->nickname,
+            $sitename
+        );
+
+        $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);
             break;
         case 'rss':
-            $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
+
+            $this->showRssTimeline(
+                $this->notices,
+                $title,
+                $link,
+                $subtitle,
+                null,
+                $logo,
+                $self
+            );
             break;
         case 'atom':
 
-            $target_id = $this->arg('id');
-
-            if (isset($target_id)) {
-                $selfuri = common_root_url() .
-                  'api/statuses/friends_timeline/' .
-                  $target_id . '.atom';
-            } else {
-                $selfuri = common_root_url() .
-                  'api/statuses/friends_timeline.atom';
-            }
-
-            $this->showAtomTimeline(
-                                    $this->notices, $title, $id, $link,
-                                    $subtitle, null, $selfuri, $logo
-                                    );
+            header('Content-Type: application/atom+xml; charset=utf-8');
+
+            $atom = new AtomNoticeFeed();
+
+            $atom->setId($id);
+            $atom->setTitle($title);
+            $atom->setSubtitle($subtitle);
+            $atom->setLogo($logo);
+            $atom->setUpdated('now');
+            $atom->addLink($link);
+            $atom->setSelfLink($self);
+
+            $atom->addEntryFromNotices($this->notices);
+
+            $this->raw($atom->getString());
+
             break;
         case 'json':
             $this->showJsonTimeline($this->notices);
             break;
         default:
-            $this->clientError(_('API method not found!'), $code = 404);
+            $this->clientError(_('API method not found.'), $code = 404);
             break;
         }
     }
@@ -171,11 +189,11 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
         if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
             $notice = $this->user->ownFriendsTimeline(($this->page-1) * $this->count,
                                                       $this->count, $this->since_id,
-                                                      $this->max_id, $this->since);
+                                                      $this->max_id);
         } else {
             $notice = $this->user->friendsTimeline(($this->page-1) * $this->count,
                                                    $this->count, $this->since_id,
-                                                   $this->max_id, $this->since);
+                                                   $this->max_id);
         }
 
         while ($notice->fetch()) {