]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apifriendshipscreate.php
Merge branch 'master' of git.gnu.io:gnu/gnu-social into nightly
[quix0rs-gnu-social.git] / actions / apifriendshipscreate.php
index 873883c6513bd4ea8bac56c2dd2ebe79cedd5edb..3997a8b51c4161d48621e0112bb143fe7683903f 100644 (file)
@@ -29,9 +29,7 @@
  * @link      http://status.net/
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
  * Allows the authenticating users to follow (subscribe) the user specified in
@@ -90,7 +88,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
             $this->clientError(_('Could not follow user: profile not found.'), 403);
         }
 
-        if ($this->user->isSubscribed($this->other)) {
+        if ($this->scoped->isSubscribed($this->other)) {
             $errmsg = sprintf(
                 // TRANS: Client error displayed when trying to follow a user that's already being followed.
                 // TRANS: %s is the nickname of the user that is already being followed.
@@ -101,9 +99,9 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
         }
 
         try {
-            Subscription::start($this->user->getProfile(), $this->other);
-        } catch (Exception $e) {
-            $this->clientError($e->getMessage(), 403);
+            Subscription::start($this->scoped, $this->other);
+        } catch (AlreadyFulfilledException $e) {
+            $this->clientError($e->getMessage(), 409);
         }
 
         $this->initDocument($this->format);