]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/command.php
Upgrade XML output scrubbing to better deal with newline and a few other chars
[quix0rs-gnu-social.git] / lib / command.php
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());
         }
     }
 }