]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelineuser.php
Fixes to Deleted_notice
[quix0rs-gnu-social.git] / actions / apitimelineuser.php
index ac33beada40f21a0bf78984e745f0148f214c251..e8c58e6e8b85d405d596b407484e3699d2d66b5c 100644 (file)
@@ -59,6 +59,8 @@ class ApiTimelineUserAction extends ApiBareAuthAction
 {
     var $notices = null;
 
+    var $next_id = null;
+
     /**
      * Take arguments for running
      *
@@ -77,6 +79,10 @@ class ApiTimelineUserAction extends ApiBareAuthAction
             $this->clientError(_('No such user.'), 404);
         }
 
+        if (!$this->target->isLocal()) {
+            $this->serverError(_('Remote user timelines are not available here yet.'), 501);
+        }
+
         $this->notices = $this->getNotices();
 
         return true;
@@ -126,16 +132,23 @@ class ApiTimelineUserAction extends ApiBareAuthAction
 
 
         // paging links
-        $nextUrl = common_local_url('ApiTimelineUser',
+        $nextUrl = !empty($this->next_id)
+                    ? common_local_url('ApiTimelineUser',
                                     array('format' => $this->format,
                                           'id' => $this->target->id),
-                                    array('max_id' => $this->next_id));
-        $lastNotice = $this->notices[0];
-        $lastId     = $lastNotice->id;
+                                    array('max_id' => $this->next_id))
+                    : null;
+
+        $prevExtra = array();
+        if (!empty($this->notices)) {
+            assert($this->notices[0] instanceof Notice);
+            $prevExtra['since_id'] = $this->notices[0]->id;
+        }
+
         $prevUrl = common_local_url('ApiTimelineUser',
                                     array('format' => $this->format,
                                           'id' => $this->target->id),
-                                    array('since_id' => $lastId));
+                                    $prevExtra);
         $firstUrl = common_local_url('ApiTimelineUser',
                                     array('format' => $this->format,
                                           'id' => $this->target->id));
@@ -166,22 +179,18 @@ class ApiTimelineUserAction extends ApiBareAuthAction
             // change too quickly!
 
             if (!empty($this->next_id)) {
-
                 $atom->addLink($nextUrl,
                                array('rel' => 'next',
                                      'type' => 'application/atom+xml'));
             }
 
             if (($this->page > 1 || !empty($this->max_id)) && !empty($this->notices)) {
-
-
                 $atom->addLink($prevUrl,
                                array('rel' => 'prev',
                                      'type' => 'application/atom+xml'));
             }
 
             if ($this->page > 1 || !empty($this->since_id) || !empty($this->max_id)) {
-
                 $atom->addLink($firstUrl,
                                array('rel' => 'first',
                                      'type' => 'application/atom+xml'));
@@ -224,7 +233,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
             break;
         default:
             // TRANS: Client error displayed when coming across a non-supported API method.
-            $this->clientError(_('API method not found.'), $code = 404);
+            $this->clientError(_('API method not found.'), 404);
         }
     }
 
@@ -400,7 +409,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
 
         // Get (safe!) HTML and text versions of the content
 
-        $rendered = $this->purify($sourceContent);
+        $rendered = common_purify($sourceContent);
         $content = common_strip_html($rendered);
 
         $shortened = $this->auth_user->shortenLinks($content);
@@ -499,13 +508,4 @@ class ApiTimelineUserAction extends ApiBareAuthAction
 
         return $saved;
     }
-
-    function purify($content)
-    {
-        require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
-
-        $config = array('safe' => 1,
-                        'deny_attribute' => 'id,style,on*');
-        return htmLawed($content, $config);
-    }
 }