Merge branch 'master' of git@gitorious.org:statusnet/mainline
This commit is contained in:
commit
af76e05cd1
@ -99,6 +99,12 @@ class TwitapifriendshipsAction extends TwitterapiAction
|
|||||||
$other = $this->get_profile($id);
|
$other = $this->get_profile($id);
|
||||||
$user = $apidata['user']; // Alwyas the auth user
|
$user = $apidata['user']; // Alwyas the auth user
|
||||||
|
|
||||||
|
if ($user->id == $other->id) {
|
||||||
|
$this->clientError(_("You cannot unfollow yourself!"),
|
||||||
|
403, $apidata['content-type']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$sub = new Subscription();
|
$sub = new Subscription();
|
||||||
$sub->subscriber = $user->id;
|
$sub->subscriber = $user->id;
|
||||||
$sub->subscribed = $other->id;
|
$sub->subscribed = $other->id;
|
||||||
|
@ -165,7 +165,7 @@ class TwittersettingsAction extends ConnectSettingsAction
|
|||||||
($flink->noticesync & FOREIGN_NOTICE_RECV) :
|
($flink->noticesync & FOREIGN_NOTICE_RECV) :
|
||||||
false);
|
false);
|
||||||
$this->elementEnd('li');
|
$this->elementEnd('li');
|
||||||
|
} else {
|
||||||
// preserve setting even if bidrection bridge toggled off
|
// preserve setting even if bidrection bridge toggled off
|
||||||
|
|
||||||
if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) {
|
if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) {
|
||||||
|
@ -21,6 +21,7 @@ VALUES
|
|||||||
('identichat','identichat','http://identichat.prosody.im/', now()),
|
('identichat','identichat','http://identichat.prosody.im/', now()),
|
||||||
('IdentiFox','IdentiFox','http://www.bitbucket.org/uncryptic/identifox/', now()),
|
('IdentiFox','IdentiFox','http://www.bitbucket.org/uncryptic/identifox/', now()),
|
||||||
('identitwitch','IdentiTwitch','http://richfish.org/identitwitch/', now()),
|
('identitwitch','IdentiTwitch','http://richfish.org/identitwitch/', now()),
|
||||||
|
('Jiminy','Jiminy','http://code.google.com/p/jiminy/', now()),
|
||||||
('LaTwit','LaTwit','http://latwit.mac65.com/', now()),
|
('LaTwit','LaTwit','http://latwit.mac65.com/', now()),
|
||||||
('LiveTweeter', 'LiveTweeter', 'http://addons.songbirdnest.com/addon/1204', now()),
|
('LiveTweeter', 'LiveTweeter', 'http://addons.songbirdnest.com/addon/1204', now()),
|
||||||
('livetweeter', 'livetweeter', 'http://addons.songbirdnest.com/addon/1204', now()),
|
('livetweeter', 'livetweeter', 'http://addons.songbirdnest.com/addon/1204', now()),
|
||||||
|
@ -160,6 +160,8 @@ function broadcast_twitter($notice)
|
|||||||
return broadcast_basicauth($notice, $flink);
|
return broadcast_basicauth($notice, $flink);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function broadcast_oauth($notice, $flink) {
|
function broadcast_oauth($notice, $flink) {
|
||||||
@ -173,34 +175,7 @@ function broadcast_oauth($notice, $flink) {
|
|||||||
try {
|
try {
|
||||||
$status = $client->statusesUpdate($statustxt);
|
$status = $client->statusesUpdate($statustxt);
|
||||||
} catch (OAuthClientCurlException $e) {
|
} catch (OAuthClientCurlException $e) {
|
||||||
|
return process_error($e, $flink);
|
||||||
if ($e->getMessage() == 'The requested URL returned error: 401') {
|
|
||||||
|
|
||||||
$errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' .
|
|
||||||
'Twitter OAuth access token.',
|
|
||||||
$user->nickname, $user->id);
|
|
||||||
common_log(LOG_WARNING, $errmsg);
|
|
||||||
|
|
||||||
// Bad auth token! We need to delete the foreign_link
|
|
||||||
// to Twitter and inform the user.
|
|
||||||
|
|
||||||
remove_twitter_link($flink);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Some other error happened, so we should probably
|
|
||||||
// try to send again later.
|
|
||||||
|
|
||||||
$errmsg = sprintf('cURL error trying to send notice to Twitter ' .
|
|
||||||
'for user %1$s (user id: %2$s) - ' .
|
|
||||||
'code: %3$s message: $4$s.',
|
|
||||||
$user->nickname, $user->id,
|
|
||||||
$e->getCode(), $e->getMessage());
|
|
||||||
common_log(LOG_WARNING, $errmsg);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($status)) {
|
if (empty($status)) {
|
||||||
@ -208,7 +183,7 @@ function broadcast_oauth($notice, $flink) {
|
|||||||
// This could represent a failure posting,
|
// This could represent a failure posting,
|
||||||
// or the Twitter API might just be behaving flakey.
|
// or the Twitter API might just be behaving flakey.
|
||||||
|
|
||||||
$errmsg = sprintf('No data returned by Twitter API when ' .
|
$errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' .
|
||||||
'trying to send update for %1$s (user id %2$s).',
|
'trying to send update for %1$s (user id %2$s).',
|
||||||
$user->nickname, $user->id);
|
$user->nickname, $user->id);
|
||||||
common_log(LOG_WARNING, $errmsg);
|
common_log(LOG_WARNING, $errmsg);
|
||||||
@ -218,7 +193,7 @@ function broadcast_oauth($notice, $flink) {
|
|||||||
|
|
||||||
// Notice crossed the great divide
|
// Notice crossed the great divide
|
||||||
|
|
||||||
$msg = sprintf('Twitter bridge posted notice %s to Twitter using OAuth.',
|
$msg = sprintf('Twitter bridge - posted notice %s to Twitter using OAuth.',
|
||||||
$notice->id);
|
$notice->id);
|
||||||
common_log(LOG_INFO, $msg);
|
common_log(LOG_INFO, $msg);
|
||||||
|
|
||||||
@ -237,33 +212,12 @@ function broadcast_basicauth($notice, $flink)
|
|||||||
try {
|
try {
|
||||||
$status = $client->statusesUpdate($statustxt);
|
$status = $client->statusesUpdate($statustxt);
|
||||||
} catch (BasicAuthCurlException $e) {
|
} catch (BasicAuthCurlException $e) {
|
||||||
|
return process_error($e, $flink);
|
||||||
if ($e->getMessage() == 'The requested URL returned error: 401') {
|
|
||||||
|
|
||||||
$errmsg = sprintf('User %1$s (user id: %2$s) has an invalid ' .
|
|
||||||
'Twitter screen_name/password combo.',
|
|
||||||
$user->nickname, $user->id);
|
|
||||||
common_log(LOG_WARNING, $errmsg);
|
|
||||||
|
|
||||||
remove_twitter_link($flink);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$errmsg = sprintf('cURL error trying to send notice to Twitter ' .
|
|
||||||
'for user %1$s (user id: %2$s) - ' .
|
|
||||||
'code: %3$s message: $4$s.',
|
|
||||||
$user->nickname, $user->id,
|
|
||||||
$e->getCode(), $e->getMessage());
|
|
||||||
common_log(LOG_WARNING, $errmsg);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($status)) {
|
if (empty($status)) {
|
||||||
|
|
||||||
$errmsg = sprintf('No data returned by Twitter API when ' .
|
$errmsg = sprintf('Twitter bridge - No data returned by Twitter API when ' .
|
||||||
'trying to send update for %1$s (user id %2$s).',
|
'trying to send update for %1$s (user id %2$s).',
|
||||||
$user->nickname, $user->id);
|
$user->nickname, $user->id);
|
||||||
common_log(LOG_WARNING, $errmsg);
|
common_log(LOG_WARNING, $errmsg);
|
||||||
@ -271,12 +225,44 @@ function broadcast_basicauth($notice, $flink)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg = sprintf('Twitter bridge posted notice %s to Twitter using basic auth.',
|
$msg = sprintf('Twitter bridge - posted notice %s to Twitter using basic auth.',
|
||||||
$notice->id);
|
$notice->id);
|
||||||
common_log(LOG_INFO, $msg);
|
common_log(LOG_INFO, $msg);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function process_error($e, $flink)
|
||||||
|
{
|
||||||
|
$user = $flink->getUser();
|
||||||
|
$errmsg = $e->getMessage();
|
||||||
|
$delivered = false;
|
||||||
|
|
||||||
|
switch($errmsg) {
|
||||||
|
case 'The requested URL returned error: 401':
|
||||||
|
$logmsg = sprintf('Twiter bridge - User %1$s (user id: %2$s) has an invalid ' .
|
||||||
|
'Twitter screen_name/password combo or an invalid acesss token.',
|
||||||
|
$user->nickname, $user->id);
|
||||||
|
$delivered = true;
|
||||||
|
remove_twitter_link($flink);
|
||||||
|
break;
|
||||||
|
case 'The requested URL returned error: 403':
|
||||||
|
$logmsg = sprintf('Twitter bridge - User %1$s (user id: %2$s) has exceeded ' .
|
||||||
|
'his/her Twitter request limit.',
|
||||||
|
$user->nickname, $user->id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$logmsg = sprintf('Twitter bridge - cURL error trying to send notice to Twitter ' .
|
||||||
|
'for user %1$s (user id: %2$s) - ' .
|
||||||
|
'code: %3$s message: %4$s.',
|
||||||
|
$user->nickname, $user->id,
|
||||||
|
$e->getCode(), $e->getMessage());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
common_log(LOG_WARNING, $logmsg);
|
||||||
|
|
||||||
|
return $delivered;
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_status($notice)
|
function format_status($notice)
|
||||||
|
Loading…
Reference in New Issue
Block a user