replace calls to subs_(un)subscribe_user with Subscription methods

This commit is contained in:
Evan Prodromou 2010-02-19 08:31:20 -05:00
parent 52e8aa798a
commit b0a75a2ab2
2 changed files with 24 additions and 14 deletions

View 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);

View 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());
}
}
}