]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apifriendshipsdestroy.php
Fix inconsistencies in clientError() messages
[quix0rs-gnu-social.git] / actions / apifriendshipsdestroy.php
index fb73624c9aab05242c168861ec1ca36dd9e814d6..d48a577562af968e259899c56e5a32edb8a79933 100644 (file)
@@ -97,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
             );
@@ -113,23 +113,20 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
             return;
         }
 
-        // Do not allow unsubscribing from yourself!
+        // Don't allow unsubscribing from yourself!
 
         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);
-
-        if (is_string($result)) {
-            $this->clientError($result, 403, $this->format);
-            return;
-        }
+        // throws an exception on error
+        Subscription::cancel($this->user->getProfile(),
+                             $this->other->getProfile());
 
         $this->initDocument($this->format);
         $this->showProfile($this->other, $this->format);