]> 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 ecc4a3f03301b92651dea1d5fe522f8792214f27..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,44 +51,17 @@ 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->user = $this->auth_user;
-
-        if ($this->user->id == $this->original->profile_id) {
-            // TRANS: Client error displayed trying to repeat an own notice through the API.
-            $this->clientError(_('Cannot repeat your own notice.'),
-                               400, $this->format);
-            return false;
-        }
-
-        $profile = $this->user->getProfile();
-
-        if ($profile->hasRepeated($id)) {
-            // TRANS: Client error displayed trying to re-repeat a notice through the API.
-            $this->clientError(_('Already repeated that notice.'),
-                               400, $this->format);
-            return false;
+            $this->clientError(_('No such notice.'), 400, $this->format);
         }
 
         return true;
@@ -106,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);
     }