aboutsummaryrefslogtreecommitdiff
path: root/src/commands/follow.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2017-11-10 04:04:00 -0800
committeriximeow <me@iximeow.net>2017-11-10 04:04:59 -0800
commit83107e0e93cad31152ce71b6a20da466d5216071 (patch)
tree877f3c97781efd2a8a5a28e1803314575b04382c /src/commands/follow.rs
parentc2c125a83cfdd3556df37f02907edcb1351d674b (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())
+ };
}