3 * StatusNet, the distributed open-source microblogging tool
5 * Show authenticating user's most recent notices that have been repeated
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
35 * Show authenticating user's most recent notices that have been repeated
39 * @author Evan Prodromou <evan@status.net>
40 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41 * @link http://status.net/
43 class ApiTimelineRetweetsOfMeAction extends ApiAuthAction
45 const DEFAULTCOUNT = 20;
47 const MAXNOTICES = 3200;
50 var $cnt = self::DEFAULTCOUNT;
56 * Take arguments for running
58 * @param array $args $_REQUEST args
60 * @return boolean success flag
62 function prepare(array $args = array())
64 parent::prepare($args);
66 $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1);
68 $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt));
70 $since_id = $this->int('since_id');
72 $max_id = $this->int('max_id');
80 * show a timeline of the user's repeated notices
82 * @param array $args $_REQUEST data (unused)
90 $offset = ($this->page-1) * $this->cnt;
93 // TRANS: Title of list of repeated notices of the logged in user.
94 // TRANS: %s is the nickname of the logged in user.
95 $title = sprintf(_("Repeats of %s"), $this->auth_user->nickname);
96 $sitename = common_config('site', 'name');
98 $profile = $this->auth_user->getProfile();
101 // TRANS: Subtitle of API time with retweets of me.
102 // TRANS: %1$s is the StatusNet sitename, %2$s is the user nickname, %3$s is the user profile name.
103 _('%1$s notices that %2$s / %3$s has repeated.'),
104 $sitename, $this->auth_user->nickname, $profile->getBestName()
107 $taguribase = TagURI::base();
108 $id = "tag:$taguribase:RepeatsOfMe:" . $this->auth_user->id;
110 $link = common_local_url(
112 array('nickname' => $this->auth_user->nickname)
115 // This is a really bad query for some reason
117 if (!common_config('performance', 'high')) {
118 $strm = $this->auth_user->repeatsOfMe($offset, $limit, $this->since_id, $this->max_id);
120 $strm = new Notice();
121 $strm->whereAdd('0 = 1');
125 switch ($this->format) {
127 $this->showXmlTimeline($strm);
130 $this->showJsonTimeline($strm);
133 header('Content-Type: application/atom+xml; charset=utf-8');
134 $atom = new AtomNoticeFeed($this->auth_user);
136 $atom->setTitle($title);
137 $atom->setSubtitle($subtitle);
138 $atom->setUpdated('now');
139 $atom->addLink($link);
140 $atom->setSelfLink($this->getSelfUri());
141 $atom->addEntryFromNotices($strm);
142 $this->raw($atom->getString());
145 header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
146 $doc = new ActivityStreamJSONDocument($this->auth_user);
147 $doc->setTitle($title);
148 $doc->addLink($link, 'alternate', 'text/html');
149 $doc->addItemsFromNotices($strm);
150 $this->raw($doc->asString());
153 // TRANS: Client error displayed when coming across a non-supported API method.
154 $this->clientError(_('API method not found.'), 404);
160 * Return true if read only.
164 * @param array $args other arguments
166 * @return boolean is read only action?
168 function isReadOnly($args)