aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2017-11-19 03:27:59 -0800
committeriximeow <me@iximeow.net>2017-11-19 03:27:59 -0800
commit0fb90e1ff2c89c403c6668064766df0aa202b2a1 (patch)
tree2c15568ea02c682de71aa4e9193ac0b8748d32e1 /src/commands
parentc8cdc9973142eed58e4731ba6199b273303cd6c4 (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.rs20
-rw-r--r--src/commands/mod.rs2
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,