X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapistatusesretweet.php;h=922d395154f2a364c410dca2b45cf57f9c2ededf;hb=d816af9aa9ac1e41f0aa4f580ab36bdf043cc3b5;hp=ecc4a3f03301b92651dea1d5fe522f8792214f27;hpb=693fecc44a70e25d5ef0ca784a462aadb487ef1e;p=quix0rs-gnu-social.git diff --git a/actions/apistatusesretweet.php b/actions/apistatusesretweet.php index ecc4a3f033..922d395154 100644 --- a/actions/apistatusesretweet.php +++ b/actions/apistatusesretweet.php @@ -27,12 +27,7 @@ * @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); }