123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class ApiFriendshipsDestroyAction extends ApiAuthAction
- {
- var $other = null;
-
- function prepare($args)
- {
- parent::prepare($args);
- $this->user = $this->auth_user;
- $this->other = $this->getTargetProfile($this->arg('id'));
- return true;
- }
-
- function handle($args)
- {
- parent::handle($args);
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->clientError(
-
- _('This method requires a POST.'),
- 400,
- $this->format
- );
- return;
- }
- if (!in_array($this->format, array('xml', 'json'))) {
- $this->clientError(
-
- _('API method not found.'),
- 404,
- $this->format
- );
- return;
- }
- if (empty($this->other)) {
- $this->clientError(
-
- _('Could not unfollow user: User not found.'),
- 403,
- $this->format
- );
- return;
- }
-
- if ($this->user->id == $this->other->id) {
- $this->clientError(
-
- _("You cannot unfollow yourself."),
- 403,
- $this->format
- );
- return;
- }
-
- Subscription::cancel($this->user->getProfile(), $this->other);
- $this->initDocument($this->format);
- $this->showProfile($this->other, $this->format);
- $this->endDocument($this->format);
- }
- }
|