replace calls to subs_(un)subscribe_user with Subscription methods
This commit is contained in:
parent
52e8aa798a
commit
b0a75a2ab2
@ -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);
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user