From 83107e0e93cad31152ce71b6a20da466d5216071 Mon Sep 17 00:00:00 2001 From: iximeow Date: Fri, 10 Nov 2017 04:04:00 -0800 Subject: very hackily add notion of user credentials and PIN auth also fix bug where cached user info takes precedence over (possibly updated) api json user info --- src/commands/follow.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/commands/follow.rs') diff --git a/src/commands/follow.rs b/src/commands/follow.rs index b0dc8a7..e9099c9 100644 --- a/src/commands/follow.rs +++ b/src/commands/follow.rs @@ -14,7 +14,13 @@ pub static UNFOLLOW: Command = Command { fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { let screen_name = line.trim(); - match queryer.do_api_post(&format!("{}?screen_name={}", FOLLOW_URL, screen_name)) { + let result = match tweeter.profile.clone() { + Some(user_creds) => { + queryer.do_api_post(&format!("{}?screen_name={}", FOLLOW_URL, screen_name), &tweeter.app_key, &user_creds) + }, + None => Err("No logged in user to unfollow from".to_owned()) + }; + match result { Ok(_resp) => (), Err(e) => tweeter.display_info.status(format!("unfl request error: {}", e)) } @@ -28,5 +34,19 @@ pub static FOLLOW: Command = Command { fn fl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { let screen_name = line.trim(); - tweeter.display_info.status(format!("fl resp: {:?}", queryer.do_api_post(&format!("{}?screen_name={}", UNFOLLOW_URL, screen_name)))); + match tweeter.profile.clone() { + Some(user_creds) => { + tweeter.display_info.status( + format!( + "fl resp: {:?}", + queryer.do_api_post( + &format!("{}?screen_name={}", UNFOLLOW_URL, screen_name), + &tweeter.app_key, + &user_creds + ) + ) + ) + }, + None => tweeter.display_info.status("No logged in user to follow from".to_owned()) + }; } -- cgit v1.1