X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapistatusesretweet.php;h=922d395154f2a364c410dca2b45cf57f9c2ededf;hb=fb4b004435403dd0d4126a0c11c9fa5c557e9dba;hp=6e6ebb038f8c83d6b8aa755fc4f6b738a4512aed;hpb=0a19674c9f61d008069b5d9607179ea2dd7807f3;p=quix0rs-gnu-social.git diff --git a/actions/apistatusesretweet.php b/actions/apistatusesretweet.php index 6e6ebb038f..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,68 +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->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; - } - - // Is it OK to repeat that notice (general enough scope)? - - if ($this->original->scope != Notice::SITE_SCOPE && - $this->original->scope != Notice::PUBLIC_SCOPE) { - // TRANS: Client error displayed when trying to repeat a private notice. - $this->clientError(_('You may not repeat a private notice.'), - 403, - $this->format); - return false; + $this->clientError(_('No such notice.'), 400, $this->format); } - $profile = $this->user->getProfile(); - - // Can the profile actually see that notice? - - if (!$this->original->inScope($profile)) { - // TRANS: Client error displayed when trying to repeat a notice the user has no access to. - $this->clientError(_('No access to that notice.'), - 403, - $this->format); - return false; - } - - 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; - } - - return true; } @@ -128,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); }