summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-07-10 09:51:49 -0400
committerEvan Prodromou <evan@status.net>2010-07-10 09:51:49 -0400
commitd53d0f7908f0a8338d9f08401ed917ee98e25ce4 (patch)
treeec385ae87ceb70814298eda8f4d12e252e473ea9
parent869ebb7dc7a5f4241b94512646cdd7ae89e35962 (diff)
parent4c5098cd32599a2c376beaadb43cd9d471477c90 (diff)
Merge branch 'master' of gitorious.org:statusnet/mainline
-rw-r--r--classes/Foreign_user.php16
-rw-r--r--plugins/TwitterBridge/twitter.php21
2 files changed, 35 insertions, 2 deletions
diff --git a/classes/Foreign_user.php b/classes/Foreign_user.php
index 0dd94ffb9..e98a16064 100644
--- a/classes/Foreign_user.php
+++ b/classes/Foreign_user.php
@@ -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();
diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php
index 896eee2da..306ba2442 100644
--- a/plugins/TwitterBridge/twitter.php
+++ b/plugins/TwitterBridge/twitter.php
@@ -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);