]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apifriendshipscreate.php
Group logos would not be fetched
[quix0rs-gnu-social.git] / actions / apifriendshipscreate.php
index 89557f8392f6ce1065dab16145c0461a099826bf..9c410f379a08f648beb098ceb7e88564b0418989 100644 (file)
@@ -33,8 +33,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Allows the authenticating users to follow (subscribe) the user specified in
  * the ID parameter.  Returns the befriended user in the requested format when
@@ -95,7 +93,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
 
         if (!in_array($this->format, array('xml', 'json'))) {
             $this->clientError(
-                // TRANS: Client error displayed when trying to handle an unknown API method.
+                // TRANS: Client error displayed when coming across a non-supported API method.
                 _('API method not found.'),
                 404,
                 $this->format
@@ -124,11 +122,10 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
             return;
         }
 
-        $result = subs_subscribe_to($this->user, $this->other);
-
-        if (is_string($result)) {
-            $this->clientError($result, 403, $this->format);
-            return;
+        try {
+            Subscription::start($this->user->getProfile(), $this->other);
+        } catch (Exception $e) {
+            $this->clientError($e->getMessage(), 403, $this->format);
         }
 
         $this->initDocument($this->format);