- parent::handle($args);
- if ($this->boolean('ajax')) {
- StatusNet::setApi(true);
- }
- if (!common_logged_in()) {
- $this->clientError(_('Not logged in.'));
- return;
- }
-
- $user = common_current_user();
-
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- common_redirect(common_local_url('subscriptions',
- array('nickname' => $user->nickname)));
- return;
- }
-
- /* Use a session token for CSRF protection. */
-
- $token = $this->trimmed('token');
-
- if (!$token || $token != common_session_token()) {
- $this->clientError(_('There was a problem with your session token. ' .
- 'Try again, please.'));
- return;
+ $profile_id = $this->int('unsubscribeto');
+ $this->target = Profile::getKV('id', $profile_id);
+ if (!$this->target instanceof Profile) {
+ throw new NoProfileException($profile_id);