summaryrefslogtreecommitdiff
path: root/lib/command.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-19 08:31:20 -0500
committerEvan Prodromou <evan@status.net>2010-02-19 08:31:20 -0500
commitb0a75a2ab24673452674a8f296ca4dbb110bed6b (patch)
tree489012ad4a9a21850f77b3e10c206673ed1a4765 /lib/command.php
parent52e8aa798a23b2832a748189b42c3bc77d65c9c7 (diff)
replace calls to subs_(un)subscribe_user with Subscription methods
Diffstat (limited to 'lib/command.php')
-rw-r--r--lib/command.php29
1 files changed, 21 insertions, 8 deletions
diff --git a/lib/command.php b/lib/command.php
index 2a51fd687..ea7b60372 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -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());
}
}
}