X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ffinishremotesubscribe.php;h=df5fe647601c7b37e09ce2337167fb064b2b75e1;hb=2abe10b8ea4b5d69fc7f6513bf465541454ca2cf;hp=bce2447ac7a256a05d53e3983582956da0989530;hpb=038f762bce95323ac929b0635cceb7f9425527ec;p=quix0rs-gnu-social.git diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index bce2447ac7..df5fe64760 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -23,10 +23,6 @@ require_once(INSTALLDIR.'/lib/omb.php'); class FinishremotesubscribeAction extends Action { - function is_readonly() { - return false; - } - function handle($args) { parent::handle($args); @@ -45,6 +41,7 @@ class FinishremotesubscribeAction extends Action { common_debug('stored request: '.print_r($omb,true), __FILE__); + common_remove_magic_from_request(); $req = OAuthRequest::from_request(); $token = $req->get_parameter('oauth_token'); @@ -82,6 +79,11 @@ class FinishremotesubscribeAction extends Action { return; } + if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) { + common_user_error(_('You can use the local subscription!')); + return; + } + common_debug('listenee: "'.$omb['listenee'].'"', __FILE__); $user = User::staticGet('nickname', $omb['listenee']); @@ -91,6 +93,13 @@ class FinishremotesubscribeAction extends Action { return; } + $other = User::staticGet('uri', $omb['listener']); + + if ($other) { + common_user_error(_('You can use the local subscription!')); + return; + } + $fullname = $req->get_parameter('omb_listener_fullname'); $homepage = $req->get_parameter('omb_listener_homepage'); $bio = $req->get_parameter('omb_listener_bio'); @@ -173,6 +182,11 @@ class FinishremotesubscribeAction extends Action { } } + if ($user->hasBlocked($remote->id)) { + $this->client_error(_('That user has blocked you from subscribing.')); + return; + } + $sub = new Subscription(); $sub->subscriber = $remote->id; $sub->subscribed = $user->id; @@ -185,6 +199,10 @@ class FinishremotesubscribeAction extends Action { return; } + # Notify user, if necessary + + mail_subscribe_notify_profile($user, $profile); + # Clear the data unset($_SESSION['oauth_authorization_request']); @@ -236,7 +254,8 @@ class FinishremotesubscribeAction extends Action { $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); $result = $fetcher->post($req->get_normalized_http_url(), - $req->to_postdata()); + $req->to_postdata(), + array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); common_debug('got result: "'.print_r($result,TRUE).'"', __FILE__); @@ -248,4 +267,4 @@ class FinishremotesubscribeAction extends Action { return array($return['oauth_token'], $return['oauth_token_secret']); } -} \ No newline at end of file +}