X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapifriendshipsdestroy.php;h=d48a577562af968e259899c56e5a32edb8a79933;hb=ddb656fcd2a3233b26e28987d2f3425944908d30;hp=2743780519c90b720001839d1191dfb619a8f2c1;hpb=743c844084bae75db02570d76694f4e9b79a9aa9;p=quix0rs-gnu-social.git diff --git a/actions/apifriendshipsdestroy.php b/actions/apifriendshipsdestroy.php index 2743780519..d48a577562 100644 --- a/actions/apifriendshipsdestroy.php +++ b/actions/apifriendshipsdestroy.php @@ -21,6 +21,8 @@ * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @copyright 2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 @@ -31,7 +33,7 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/apiauth.php'; +require_once INSTALLDIR . '/lib/apiauth.php'; /** * Allows the authenticating users to unfollow (unsubscribe) the user specified in @@ -40,6 +42,8 @@ require_once INSTALLDIR.'/lib/apiauth.php'; * * @category API * @package StatusNet + * @author Dan Moore + * @author Evan Prodromou * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -47,7 +51,6 @@ require_once INSTALLDIR.'/lib/apiauth.php'; class ApiFriendshipsDestroyAction extends ApiAuthAction { - var $user = null; var $other = null; /** @@ -94,7 +97,7 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction if (!in_array($this->format, array('xml', 'json'))) { $this->clientError( - _('API method not found!'), + _('API method not found.'), 404, $this->format ); @@ -114,23 +117,20 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction if ($this->user->id == $this->other->id) { $this->clientError( - _("You cannot unfollow yourself!"), + _("You cannot unfollow yourself."), 403, $this->format ); return; } - $result = subs_unsubscribe_user($this->user, $this->other->nickname); + // throws an exception on error + Subscription::cancel($this->user->getProfile(), + $this->other->getProfile()); - if (is_string($result)) { - $this->clientError($result, 403, $this->format); - return; - } - - $this->init_document($this->format); - $this->show_profile($this->other, $this->format); - $this->end_document($this->format); + $this->initDocument($this->format); + $this->showProfile($this->other, $this->format); + $this->endDocument($this->format); } }