aboutsummaryrefslogtreecommitdiff
path: root/src/commands/fav.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/fav.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/fav.rs')
-rw-r--r--src/commands/fav.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/commands/fav.rs b/src/commands/fav.rs
index 6109310..08ad7f0 100644
--- a/src/commands/fav.rs
+++ b/src/commands/fav.rs
@@ -19,7 +19,11 @@ fn unfav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
match maybe_id {
Ok(twid) => {
if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self
- match queryer.do_api_post(&format!("{}?id={}", UNFAV_TWEET_URL, twete.id)) {
+ let result = match tweeter.profile.clone() {
+ Some(user_creds) => queryer.do_api_post(&format!("{}?id={}", UNFAV_TWEET_URL, twete.id), &tweeter.app_key, &user_creds),
+ None => Err("No logged in user to unfav from".to_owned())
+ };
+ match result {
Ok(_) => (),
Err(e) => tweeter.display_info.status(e)
}
@@ -45,7 +49,11 @@ fn fav(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) {
Ok(twid) => {
// tweeter.to_twitter_tweet_id(twid)...
if let Some(twete) = tweeter.retrieve_tweet(&twid).map(|x| x.clone()) { // TODO: no clone when this stops taking &mut self
- match queryer.do_api_post(&format!("{}?id={}", FAV_TWEET_URL, twete.id)) {
+ let result = match tweeter.profile.clone() {
+ Some(user_creds) => queryer.do_api_post(&format!("{}?id={}", FAV_TWEET_URL, twete.id), &tweeter.app_key, &user_creds),
+ None => Err("No logged in user to fav from".to_owned())
+ };
+ match result {
Ok(_) => (),
Err(e) => tweeter.display_info.status(e)
}