forked from GNUsocial/gnu-social
Fix for regression introduced with my last update to the
TwitterStatusFetcher: the Twitter bridge was not saving a foreign user record when making a foreign link.
This commit is contained in:
parent
6b10c269b5
commit
5cc1f8b001
@ -28,6 +28,7 @@ require_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
|
|||||||
|
|
||||||
function add_twitter_user($twitter_id, $screen_name)
|
function add_twitter_user($twitter_id, $screen_name)
|
||||||
{
|
{
|
||||||
|
common_debug("Add Twitter user");
|
||||||
|
|
||||||
$new_uri = 'http://twitter.com/' . $screen_name;
|
$new_uri = 'http://twitter.com/' . $screen_name;
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ function add_twitter_user($twitter_id, $screen_name)
|
|||||||
$luser->service = TWITTER_SERVICE;
|
$luser->service = TWITTER_SERVICE;
|
||||||
$result = $luser->delete();
|
$result = $luser->delete();
|
||||||
|
|
||||||
if (empty($result)) {
|
if ($result != false) {
|
||||||
common_log(LOG_WARNING,
|
common_log(LOG_WARNING,
|
||||||
"Twitter bridge - removed invalid Twitter user squatting on uri: $new_uri");
|
"Twitter bridge - removed invalid Twitter user squatting on uri: $new_uri");
|
||||||
}
|
}
|
||||||
@ -93,9 +94,9 @@ function save_twitter_user($twitter_id, $screen_name)
|
|||||||
$screen_name,
|
$screen_name,
|
||||||
$oldname));
|
$oldname));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return add_twitter_user($twitter_id, $screen_name);
|
return add_twitter_user($twitter_id, $screen_name);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_twitter_bound($notice, $flink) {
|
function is_twitter_bound($notice, $flink) {
|
||||||
|
@ -89,13 +89,17 @@ class TwitterauthorizationAction extends Action
|
|||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
|
$flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
|
||||||
|
|
||||||
// If there's already a foreign link record, it means we already
|
// If there's already a foreign link record and a foreign user
|
||||||
// have an access token, and this is unecessary. So go back.
|
// it means the accounts are already linked, and this is unecessary.
|
||||||
|
// So go back.
|
||||||
|
|
||||||
if (isset($flink)) {
|
if (isset($flink)) {
|
||||||
|
$fuser = $flink->getForeignUser();
|
||||||
|
if (!empty($fuser)) {
|
||||||
common_redirect(common_local_url('twittersettings'));
|
common_redirect(common_local_url('twittersettings'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
|
||||||
@ -254,6 +258,10 @@ class TwitterauthorizationAction extends Action
|
|||||||
{
|
{
|
||||||
$flink = new Foreign_link();
|
$flink = new Foreign_link();
|
||||||
|
|
||||||
|
$flink->user_id = $user_id;
|
||||||
|
$flink->service = TWITTER_SERVICE;
|
||||||
|
$flink->delete(); // delete stale flink, if any
|
||||||
|
|
||||||
$flink->user_id = $user_id;
|
$flink->user_id = $user_id;
|
||||||
$flink->foreign_id = $twuid;
|
$flink->foreign_id = $twuid;
|
||||||
$flink->service = TWITTER_SERVICE;
|
$flink->service = TWITTER_SERVICE;
|
||||||
|
Loading…
Reference in New Issue
Block a user