aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/auth.rs27
-rw-r--r--src/tw/mod.rs5
2 files changed, 28 insertions, 4 deletions
diff --git a/src/commands/auth.rs b/src/commands/auth.rs
index 9b83c66..17503d5 100644
--- a/src/commands/auth.rs
+++ b/src/commands/auth.rs
@@ -92,9 +92,6 @@ fn pin(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp
*
* fallback to asking user to name the profile, i guess?
*/
- if tweeter.curr_profile.is_none() {
- tweeter.curr_profile = Some("default".to_owned());
- }
let user_credential = tw::Credential {
key: as_map["oauth_token"].to_owned(),
secret: as_map["oauth_token_secret"].to_owned()
@@ -103,7 +100,29 @@ fn pin(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp
match queryer.do_api_get(::ACCOUNT_SETTINGS_URL, &tweeter.app_key, &user_credential) {
Ok(settings) => {
let user_handle = settings["screen_name"].as_str().unwrap().to_owned();
- tweeter.add_profile(tw::TwitterProfile::new(user_credential, tw::user::User::default()), Some(user_handle.clone()), display_info);
+ /*
+ * kinda gotta hand-crank this to set up the user profile...
+ * largely the same logic as `look_up_user`.
+ */
+ let looked_up_user = queryer.do_api_get(
+ &format!("{}?screen_name={}", ::USER_LOOKUP_URL, user_handle),
+ &tweeter.app_key,
+ &user_credential
+ ).and_then(|json| tw::user::User::from_json(json));
+
+ let profile_user = match looked_up_user {
+ Ok(user) => user,
+ Err(e) => {
+ display_info.status("Couldn't look up you up - handle and display name are not set. You'll have to manually adjust cache/profile.json.".to_owned());
+ display_info.status(format!("Lookup error: {}", e));
+ tw::user::User::default()
+ }
+ };
+ display_info.status(format!("wtf at auth curr_profile is {:?}", tweeter.curr_profile));
+ if tweeter.curr_profile.is_none() {
+ tweeter.curr_profile = Some(user_handle.to_owned());
+ }
+ tweeter.add_profile(tw::TwitterProfile::new(user_credential, profile_user), Some(user_handle.clone()), display_info);
tweeter.WIP_auth = None;
tweeter.state = tw::AppState::Reconnect(user_handle);
display_info.status("Looks like you authed! Connecting...".to_owned());
diff --git a/src/tw/mod.rs b/src/tw/mod.rs
index 49759e2..0a073c9 100644
--- a/src/tw/mod.rs
+++ b/src/tw/mod.rs
@@ -1042,6 +1042,10 @@ fn handle_twitter_welcome(
match followers_changes {
Ok((my_name, new_following, lost_following, (new_followers, lost_followers))) => {
+ /*
+ * This *will* spam you on login, and isn't very useful.
+ * TODO: present this sanely.
+ *
for user in new_following {
display_info.status(format!("New following! {}", user));
}
@@ -1054,6 +1058,7 @@ fn handle_twitter_welcome(
for user in lost_followers {
display_info.status(format!("{} isn't following anymore", user));
}
+ */
},
Err(e) => {
display_info.status(e);