]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apistatusesretweet.php
Merge branch 'nightly' into repeat_as_shareplugin
[quix0rs-gnu-social.git] / actions / apistatusesretweet.php
index 4832da1823d6243d49a1122a144d4ad9607c5af1..922d395154f2a364c410dca2b45cf57f9c2ededf 100644 (file)
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
-
-require_once INSTALLDIR . '/lib/apiauth.php';
-require_once INSTALLDIR . '/lib/mediafile.php';
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Repeat a notice through the API
@@ -45,6 +40,8 @@ require_once INSTALLDIR . '/lib/mediafile.php';
  */
 class ApiStatusesRetweetAction extends ApiAuthAction
 {
+    protected $needPost = true;
+
     var $original = null;
 
     /**
@@ -54,30 +51,19 @@ class ApiStatusesRetweetAction extends ApiAuthAction
      *
      * @return boolean success flag
      */
-    function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
-        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
-            // TRANS: Client error. POST is a HTTP command. It should not be translated.
-            $this->clientError(_('This method requires a POST.'),
-                               400, $this->format);
-            return false;
-        }
-
         $id = $this->trimmed('id');
 
-        $this->original = Notice::staticGet('id', $id);
+        $this->original = Notice::getKV('id', $id);
 
-        if (empty($this->original)) {
+        if (!$this->original instanceof Notice) {
             // TRANS: Client error displayed trying to repeat a non-existing notice through the API.
-            $this->clientError(_('No such notice.'),
-                               400, $this->format);
-            return false;
+            $this->clientError(_('No such notice.'), 400, $this->format);
         }
 
-        $this->user = $this->auth_user;
-
         return true;
     }
 
@@ -90,11 +76,11 @@ class ApiStatusesRetweetAction extends ApiAuthAction
      *
      * @return void
      */
-    function handle($args)
+    protected function handle()
     {
-        parent::handle($args);
+        parent::handle();
 
-        $repeat = $this->original->repeat($this->user->id, $this->source);
+        $repeat = $this->original->repeat($this->scoped, $this->source);
 
         $this->showNotice($repeat);
     }