summaryrefslogtreecommitdiff
path: root/plugins/TwitterBridge
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-06 06:46:00 +0000
committerZach Copley <zach@status.net>2010-02-06 06:48:19 +0000
commit70abea3ac4034cbbfc68cdc8288fc7e2d1cea17c (patch)
tree5aef089d22b1e170333cfdcff6e63da7c73d206c /plugins/TwitterBridge
parent558934d1ddc1c1163c6a142bfe1c4232496b25d6 (diff)
Delete old Twitter user record when user changes screen name instead of updating. Simpler.
Diffstat (limited to 'plugins/TwitterBridge')
-rw-r--r--plugins/TwitterBridge/twitter.php54
1 files changed, 8 insertions, 46 deletions
diff --git a/plugins/TwitterBridge/twitter.php b/plugins/TwitterBridge/twitter.php
index 33dfb788b..de30d9ebf 100644
--- a/plugins/TwitterBridge/twitter.php
+++ b/plugins/TwitterBridge/twitter.php
@@ -26,38 +26,6 @@ define('TWITTER_SERVICE', 1); // Twitter is foreign_service ID 1
require_once INSTALLDIR . '/plugins/TwitterBridge/twitterbasicauthclient.php';
require_once INSTALLDIR . '/plugins/TwitterBridge/twitteroauthclient.php';
-function updateTwitter_user($twitter_id, $screen_name)
-{
- $uri = 'http://twitter.com/' . $screen_name;
- $fuser = new Foreign_user();
-
- $fuser->query('BEGIN');
-
- // Dropping down to SQL because regular DB_DataObject udpate stuff doesn't seem
- // to work so good with tables that have multiple column primary keys
-
- // Any time we update the uri for a forein user we have to make sure there
- // are no dupe entries first -- unique constraint on the uri column
-
- $qry = 'UPDATE foreign_user set uri = \'\' WHERE uri = ';
- $qry .= '\'' . $uri . '\'' . ' AND service = ' . TWITTER_SERVICE;
-
- $fuser->query($qry);
-
- // Update the user
-
- $qry = 'UPDATE foreign_user SET nickname = ';
- $qry .= '\'' . $screen_name . '\'' . ', uri = \'' . $uri . '\' ';
- $qry .= 'WHERE id = ' . $twitter_id . ' AND service = ' . TWITTER_SERVICE;
-
- $fuser->query('COMMIT');
-
- $fuser->free();
- unset($fuser);
-
- return true;
-}
-
function add_twitter_user($twitter_id, $screen_name)
{
@@ -105,7 +73,6 @@ function add_twitter_user($twitter_id, $screen_name)
// Creates or Updates a Twitter user
function save_twitter_user($twitter_id, $screen_name)
{
-
// Check to see whether the Twitter user is already in the system,
// and update its screen name and uri if so.
@@ -115,25 +82,20 @@ function save_twitter_user($twitter_id, $screen_name)
$result = true;
- // Only update if Twitter screen name has changed
+ // Delete old record if Twitter user changed screen name
if ($fuser->nickname != $screen_name) {
- $result = updateTwitter_user($twitter_id, $screen_name);
-
- common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' .
- "$fuser->id to $screen_name, was $fuser->nickname");
+ $oldname = $fuser->nickname;
+ $fuser->delete();
+ common_log(LOG_INFO, sprintf('Twitter bridge - Updated nickname (and URI) ' .
+ 'for Twitter user %1$d - %2$s, was %3$s.',
+ $fuser->id,
+ $screen_name,
+ $oldname));
}
- return $result;
-
- } else {
return add_twitter_user($twitter_id, $screen_name);
}
-
- $fuser->free();
- unset($fuser);
-
- return true;
}
function is_twitter_bound($notice, $flink) {