]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/command.php
replace calls to subs_(un)subscribe_user with Subscription methods
[quix0rs-gnu-social.git] / lib / command.php
index c0a32e1b1a4cb2184434e96bc5423a57749262cd..ea7b60372d96542dd134069d7a94b67b4d40756c 100644 (file)
@@ -422,7 +422,7 @@ class RepeatCommand extends Command
         $repeat = $notice->repeat($this->user->id, $channel->source);
 
         if ($repeat) {
-            common_broadcast_notice($repeat);
+
             $channel->output($this->user, sprintf(_('Notice from %s repeated'), $recipient->nickname));
         } else {
             $channel->error($this->user, _('Error repeating notice.'));
@@ -492,7 +492,7 @@ class ReplyCommand extends Command
         } else {
             $channel->error($this->user, _('Error saving notice.'));
         }
-        common_broadcast_notice($notice);
+
     }
 }
 
@@ -548,12 +548,19 @@ class SubCommand extends Command
             return;
         }
 
-        $result = subs_subscribe_user($this->user, $this->other);
+        $otherUser = User::staticGet('nickname', $this->other);
+
+        if (empty($otherUser)) {
+            $channel->error($this->user, _('No such user'));
+            return;
+        }
 
-        if ($result == 'true') {
+        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 (empty($otherUser)) {
+            $channel->error($this->user, _('No such user'));
+        }
 
-        if ($result) {
+        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());
         }
     }
 }