diff options
author | Andy Wortman <ixineeringeverywhere@gmail.com> | 2017-11-19 03:27:59 -0800 |
---|---|---|
committer | Andy Wortman <ixineeringeverywhere@gmail.com> | 2017-11-19 03:27:59 -0800 |
commit | fb6974bca8878726330e2cc460e0c1ff2def1a99 (patch) | |
tree | 2c15568ea02c682de71aa4e9193ac0b8748d32e1 /src/commands | |
parent | 1de0593b707540b4c1bd03f2c0a151281a893be6 (diff) |
support reconnecting specific profiles, switching profiles
open issues: something is wrong with loading settings - something gets
replayed from main account to alternate accounts.
auth'ing a new account doesn't set handle, name, etc.
i think most issue are because events aren't recorded with what
connection they came from - welcome event for any account gets replayed
onto curr_profile because we simply don't know which connection the
event was from.
the same will happen for twitter events, but those aren't logged.
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/auth.rs | 20 | ||||
-rw-r--r-- | src/commands/mod.rs | 2 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/commands/auth.rs b/src/commands/auth.rs index 0743d4e..db3a143 100644 --- a/src/commands/auth.rs +++ b/src/commands/auth.rs @@ -94,13 +94,23 @@ fn pin(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { if tweeter.curr_profile.is_none() { tweeter.curr_profile = Some("default".to_owned()); } - tweeter.add_profile(tw::TwitterProfile::new(tw::Credential { + let user_credential = tw::Credential { key: as_map["oauth_token"].to_owned(), secret: as_map["oauth_token_secret"].to_owned() - }, tw::user::User::default()), Some("default".to_owned())); - tweeter.WIP_auth = None; - tweeter.state = tw::AppState::Reconnect; - tweeter.display_info.status("Looks like you authed! Connecting...".to_owned()); + }; + + 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())); + tweeter.WIP_auth = None; + tweeter.state = tw::AppState::Reconnect(user_handle); + tweeter.display_info.status("Looks like you authed! Connecting...".to_owned()); + }, + Err(_) => { + tweeter.display_info.status("Auth failed - couldn't find your handle.".to_owned()); + } + }; }, Err(_) => tweeter.display_info.status("couldn't rebuild url".to_owned()) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index e8efdb1..3404470 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -19,8 +19,10 @@ pub mod quit; pub mod fav; pub mod follow; pub mod thread; +pub mod profile; pub static COMMANDS: &[&Command] = &[ + &profile::PROFILE, &help::HELP, &auth::AUTH, &auth::PIN, |