]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelinepublic.php
OStatus: handle update-profile Salmon pings
[quix0rs-gnu-social.git] / actions / apitimelinepublic.php
index a635ddc91e3abc96e565166f4727ea4c2151bd3f..1ff0fd26172892defc5d48c047fe9da50ffb4423 100644 (file)
  *
  * @category  API
  * @package   StatusNet
+ * @author    Craig Andrews <candrews@integralblue.com>
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Jeffery To <jeffery.to@gmail.com>
+ * @author    mac65 <mac65@mac65.com>
+ * @author    Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author    Robin Millette <robin@millette.info>
  * @author    Zach Copley <zach@status.net>
  * @copyright 2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
@@ -31,19 +37,25 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/api.php';
+require_once INSTALLDIR . '/lib/apiprivateauth.php';
 
 /**
  * Returns the most recent notices (default 20) posted by everybody
  *
  * @category API
  * @package  StatusNet
+ * @author   Craig Andrews <candrews@integralblue.com>
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Jeffery To <jeffery.to@gmail.com>
+ * @author   mac65 <mac65@mac65.com>
+ * @author   Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author   Robin Millette <robin@millette.info>
  * @author   Zach Copley <zach@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
  */
 
-class ApiTimelinePublicAction extends ApiAction
+class ApiTimelinePublicAction extends ApiPrivateAuthAction
 {
 
     var $notices = null;
@@ -61,14 +73,12 @@ class ApiTimelinePublicAction extends ApiAction
     {
         parent::prepare($args);
 
-        $this->page     = (int)$this->arg('page', 1);
-        $this->count    = (int)$this->arg('count', 20);
-        $this->max_id   = (int)$this->arg('max_id', 0);
-        $this->since_id = (int)$this->arg('since_id', 0);
-        $this->since    = $this->arg('since');
-
         $this->notices = $this->getNotices();
 
+        if ($this->since) {
+            throw new ServerException("since parameter is disabled for performance; use since_id", 403);
+        }
+
         return true;
     }
 
@@ -97,31 +107,49 @@ class ApiTimelinePublicAction extends ApiAction
     function showTimeline()
     {
         $sitename   = common_config('site', 'name');
+        $sitelogo   = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
         $title      = sprintf(_("%s public timeline"), $sitename);
-        $taguribase = common_config('integration', 'taguri');
+        $taguribase = TagURI::base();
         $id         = "tag:$taguribase:PublicTimeline";
         $link       = common_root_url();
         $subtitle   = sprintf(_("%s updates from everyone!"), $sitename);
 
         switch($this->format) {
         case 'xml':
-            $this->show_xml_timeline($this->notices);
+            $this->showXmlTimeline($this->notices);
             break;
         case 'rss':
-            $this->show_rss_timeline($this->notices, $title, $link, $subtitle);
+            $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo);
             break;
         case 'atom':
-            $selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
-            $this->show_atom_timeline(
-                $this->notices, $title, $id, $link,
-                $subtitle, null, $selfuri
+
+            $atom = new AtomNoticeFeed();
+
+            $atom->setId($id);
+            $atom->setTitle($title);
+            $atom->setSubtitle($subtitle);
+            $atom->setLogo($sitelogo);
+            $atom->setUpdated('now');
+
+            $atom->addLink(common_local_url('public'));
+
+            $atom->addLink(
+                $this->getSelfUri(
+                    'ApiTimelinePublic', array('format' => 'atom')
+                ),
+                array('rel' => 'self', 'type' => 'application/atom+xml')
             );
+
+            $atom->addEntryFromNotices($this->notices);
+
+            $this->raw($atom->getString());
+
             break;
         case 'json':
-            $this->show_json_timeline($this->notices);
+            $this->showJsonTimeline($this->notices);
             break;
         default:
-            $this->clientError(_('API method not found!'), $code = 404);
+            $this->clientError(_('API method not found.'), $code = 404);
             break;
         }
     }
@@ -138,7 +166,7 @@ class ApiTimelinePublicAction extends ApiAction
 
         $notice = Notice::publicStream(
             ($this->page - 1) * $this->count, $this->count, $this->since_id,
-            $this->max_id, $this->since
+            $this->max_id
         );
 
         while ($notice->fetch()) {