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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = subs_unsubscribe_user($this->user, $this->other->nickname);
|
// throws an exception on error
|
||||||
|
Subscription::cancel($this->user->getProfile(),
|
||||||
if (is_string($result)) {
|
$this->other->getProfile());
|
||||||
$this->clientError($result, 403, $this->format);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->initDocument($this->format);
|
$this->initDocument($this->format);
|
||||||
$this->showProfile($this->other, $this->format);
|
$this->showProfile($this->other, $this->format);
|
||||||
|
@ -548,12 +548,19 @@ class SubCommand extends Command
|
|||||||
return;
|
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));
|
$channel->output($this->user, sprintf(_('Subscribed to %s'), $this->other));
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
$channel->error($this->user, $result);
|
$channel->error($this->user, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -576,12 +583,18 @@ class UnsubCommand extends Command
|
|||||||
return;
|
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));
|
$channel->output($this->user, sprintf(_('Unsubscribed from %s'), $this->other));
|
||||||
} else {
|
} catch (Exception $e) {
|
||||||
$channel->error($this->user, $result);
|
$channel->error($this->user, $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user