From eb81ec6d98ae0f3e64ce86efc4ac7071358c8a8e Mon Sep 17 00:00:00 2001 From: Andy Wortman Date: Sat, 2 Dec 2017 22:50:46 -0800 Subject: rebrand + fix cache/profile json also set current profile to first auth'd account, when starting from a blank slate. silence follower changes because it's not sanely displayed yet (and may never be) --- Cargo.toml | 12 +++++------- cache/profile.json | 2 +- cache/tweets.json | 0 cache/users.json | 0 src/commands/auth.rs | 27 +++++++++++++++++++++++---- src/tw/mod.rs | 5 +++++ 6 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 cache/tweets.json create mode 100644 cache/users.json diff --git a/Cargo.toml b/Cargo.toml index b1f3677..c997589 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,17 @@ [package] -name = "twidder" +name = "reifenfeuerd" version = "0.0.1" authors = [ "iximeow " ] license = "MIT" -repository = "lol" +repository = "https://github.com/iximeow/reifenfeuerd" description = """ -a nice twitter +a nice twitter client """ [[bin]] -name = "twidder" -# path = "main.rs" -#test = false -#bench = false +name = "reifenfeuerd" +path = "src/main.rs" [dependencies] "termios" = "0.2.2" diff --git a/cache/profile.json b/cache/profile.json index d267003..8839791 100644 --- a/cache/profile.json +++ b/cache/profile.json @@ -1 +1 @@ -{"app_key":{"key":"rTwEnj5avlY7UKd7rIf2wlxYe","secret":"yZU3xkDyfTj1pfcbNBOkcYTLdrWWJwOkDQXvxcNsqc5PMsDwhA"},"profile":null,"following":[],"following_history":{},"followers":[],"lost_followers":[],"follower_history":{},"threads":{}} +{"app_key":{"key":"mS0xDX2LBVOohjeHW0JsJEBhF","secret":"q54t40D7LQZgQgHScpyXan5YlTxc3qKBu8SbC7w6kH0DsBZcu9"},"profiles":{},"mutes":{"users":{},"tweets":{},"words":[]},"threads":{}} diff --git a/cache/tweets.json b/cache/tweets.json new file mode 100644 index 0000000..e69de29 diff --git a/cache/users.json b/cache/users.json new file mode 100644 index 0000000..e69de29 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); -- cgit v1.1