aboutsummaryrefslogtreecommitdiff
path: root/src/commands/follow.rs
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-11-10 04:04:00 -0800
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-11-10 04:04:59 -0800
commitca0762652e293ad9d35b03b537c02d218e44a13f (patch)
tree877f3c97781efd2a8a5a28e1803314575b04382c /src/commands/follow.rs
parentaa5f8ff4bce898907ffc0c0e2b7ea36d7f8c10b7 (diff)
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
Diffstat (limited to 'src/commands/follow.rs')
-rw-r--r--src/commands/follow.rs24
1 files changed, 22 insertions, 2 deletions
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())
+ };
}