We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit d53d0f79 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch 'master' of gitorious.org:statusnet/mainline

parents 869ebb7d 4c5098cd
......@@ -39,6 +39,22 @@ class Foreign_user extends Memcached_DataObject
return null;
}
static function getByNickname($nickname, $service)
{
if (empty($nickname) || empty($service)) {
return null;
} else {
$fuser = new Foreign_user();
$fuser->service = $service;
$fuser->nickname = $nickname;
$fuser->limit(1);
$result = $fuser->find(true);
return empty($result) ? null : $fuser;
}
}
function updateKeys(&$orig)
{
$this->_connect();
......
......@@ -75,8 +75,6 @@ function save_twitter_user($twitter_id, $screen_name)
if (!empty($fuser)) {
$result = true;
// Delete old record if Twitter user changed screen name
if ($fuser->nickname != $screen_name) {
......@@ -88,6 +86,25 @@ function save_twitter_user($twitter_id, $screen_name)
$screen_name,
$oldname));
}
} else {
// Kill any old, invalid records for this screen name
$fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE);
if (!empty($fuser)) {
$fuser->delete();
common_log(
LOG_INFO,
sprintf(
'Twitter bridge - deteted old record for Twitter ' .
'screen name "%s" belonging to Twitter ID %d.',
$screen_name,
$fuser->id
)
);
}
}
return add_twitter_user($twitter_id, $screen_name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment