123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- · ·
- · Unsilence a user ·
- · ·
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- · ·
- · ·
- · Q V I T T E R ·
- · ·
- · https://git.gnu.io/h2p/Qvitter ·
- · ·
- · ·
- · <o) ·
- · /_//// ·
- · (____/ ·
- · (o< ·
- · o> \\\\_\ ·
- · \\) \____) ·
- · ·
- · ·
- · ·
- · Qvitter is free software: you can redistribute it and / or modify it ·
- · under the terms of the GNU Affero General Public License as published by ·
- · the Free Software Foundation, either version three of the License or (at ·
- · your option) any later version. ·
- · ·
- · Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
- · WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS ·
- · FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for ·
- · more details. ·
- · ·
- · You should have received a copy of the GNU Affero General Public License ·
- · along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
- · ·
- · Contact h@nnesmannerhe.im if you have any questions. ·
- · ·
- · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ApiQvitterSilenceDestroyAction extends ApiAuthAction
- {
- protected $needPost = true;
- /**
- * Take arguments for running
- *
- * @param array $args $_REQUEST args
- *
- * @return boolean success flag
- */
- protected function prepare(array $args=array())
- {
- parent::prepare($args);
- $this->format = 'json';
- $this->other = $this->getTargetProfile($this->arg('id'));
- return true;
- }
- /**
- * Handle the request
- *
- * @param array $args $_REQUEST data (unused)
- *
- * @return void
- */
- protected function handle()
- {
- parent::handle();
- if (!$this->other instanceof Profile) {
- $this->clientError(_('No such user.'), 404);
- }
- if ($this->scoped->id == $this->other->id) {
- $this->clientError(_("You cannot unsilence yourself!"), 403);
- }
- try {
- $this->other->unsilenceAs($this->scoped);
- } catch (AlreadyFulfilledException $e) {
- // don't throw client error here, just return the user array like
- // if we successfully unsilenced the user. the client is only interested
- // in making sure the user is unsilenced.
- } catch (Exception $e) {
- $this->clientError($e->getMessage(), $e->getCode());
- }
- $this->initDocument('json');
- $this->showJsonObjects($this->twitterUserArray($this->other));
- $this->endDocument('json');
- }
- }
|