]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
replace calls to subs_(un)subscribe_user with Subscription methods
authorEvan Prodromou <evan@status.net>
Fri, 19 Feb 2010 13:31:20 +0000 (08:31 -0500)
committerEvan Prodromou <evan@status.net>
Fri, 19 Feb 2010 13:31:20 +0000 (08:31 -0500)
actions/apifriendshipsdestroy.php
lib/command.php

index 91c6fd032439e7bdc68c621fec5bcb64458ec4c1..d48a577562af968e259899c56e5a32edb8a79933 100644 (file)
@@ -124,12 +124,9 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
             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);
index 2a51fd6872835781c424cf7e718f226e73b2a79f..ea7b60372d96542dd134069d7a94b67b4d40756c 100644 (file)
@@ -548,12 +548,19 @@ class SubCommand extends Command
             return;
         }
 
-        $result = subs_subscribe_user($this->user, $this->other);
+        $otherUser = User::staticGet('nickname', $this->other);
 
-        if ($result == 'true') {
+        if (empty($otherUser)) {
+            $channel->error($this->user, _('No such user'));
+            return;
+        }
+
+        try {
+            Subscription::start($this->user->getProfile(),
+                                $otherUser->getProfile());
             $channel->output($this->user, sprintf(_('Subscribed to %s'), $this->other));
-        } else {
-            $channel->error($this->user, $result);
+        } catch (Exception $e) {
+            $channel->error($this->user, $e->getMessage());
         }
     }
 }
@@ -576,12 +583,18 @@ class UnsubCommand extends Command
             return;
         }
 
-        $result=subs_unsubscribe_user($this->user, $this->other);
+        $otherUser = User::staticGet('nickname', $this->other);
 
-        if ($result) {
+        if (empty($otherUser)) {
+            $channel->error($this->user, _('No such user'));
+        }
+
+        try {
+            Subscription::cancel($this->user->getProfile(),
+                                 $otherUser->getProfile());
             $channel->output($this->user, sprintf(_('Unsubscribed from %s'), $this->other));
-        } else {
-            $channel->error($this->user, $result);
+        } catch (Exception $e) {
+            $channel->error($this->user, $e->getMessage());
         }
     }
 }