aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-12-02 22:50:46 -0800
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-12-03 01:27:58 -0800
commiteb81ec6d98ae0f3e64ce86efc4ac7071358c8a8e (patch)
tree3306415350ea120f179286a3124bafefdeb21a7c
parent8751083a2c25d4ae374916727f96346754cee131 (diff)
rebrand + fix cache/profile json
also set current profile to first auth'd account, when starting from a blank slate. silence follower changes because it's not sanely displayed yet (and may never be)
-rw-r--r--Cargo.toml12
-rw-r--r--cache/profile.json2
-rw-r--r--cache/tweets.json0
-rw-r--r--cache/users.json0
-rw-r--r--src/commands/auth.rs27
-rw-r--r--src/tw/mod.rs5
6 files changed, 34 insertions, 12 deletions
diff --git a/Cargo.toml b/Cargo.toml
index b1f3677..c997589 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,19 +1,17 @@
[package]
-name = "twidder"
+name = "reifenfeuerd"
version = "0.0.1"
authors = [ "iximeow <me@iximeow.net>" ]
license = "MIT"
-repository = "lol"
+repository = "https://github.com/iximeow/reifenfeuerd"
description = """
-a nice twitter
+a nice twitter client
"""
[[bin]]
-name = "twidder"
-# path = "main.rs"
-#test = false
-#bench = false
+name = "reifenfeuerd"
+path = "src/main.rs"
[dependencies]
"termios" = "0.2.2"
diff --git a/cache/profile.json b/cache/profile.json
index d267003..8839791 100644
--- a/cache/profile.json
+++ b/cache/profile.json
@@ -1 +1 @@
-{"app_key":{"key":"rTwEnj5avlY7UKd7rIf2wlxYe","secret":"yZU3xkDyfTj1pfcbNBOkcYTLdrWWJwOkDQXvxcNsqc5PMsDwhA"},"profile":null,"following":[],"following_history":{},"followers":[],"lost_followers":[],"follower_history":{},"threads":{}}
+{"app_key":{"key":"mS0xDX2LBVOohjeHW0JsJEBhF","secret":"q54t40D7LQZgQgHScpyXan5YlTxc3qKBu8SbC7w6kH0DsBZcu9"},"profiles":{},"mutes":{"users":{},"tweets":{},"words":[]},"threads":{}}
diff --git a/cache/tweets.json b/cache/tweets.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cache/tweets.json
diff --git a/cache/users.json b/cache/users.json
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cache/users.json
diff --git a/src/commands/auth.rs b/src/commands/auth.rs
index 9b83c66..17503d5 100644
--- a/src/commands/auth.rs
+++ b/src/commands/auth.rs
@@ -92,9 +92,6 @@ fn pin(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp
*
* fallback to asking user to name the profile, i guess?
*/
- if tweeter.curr_profile.is_none() {
- tweeter.curr_profile = Some("default".to_owned());
- }
let user_credential = tw::Credential {
key: as_map["oauth_token"].to_owned(),
secret: as_map["oauth_token_secret"].to_owned()
@@ -103,7 +100,29 @@ fn pin(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer, disp
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()), display_info);
+ /*
+ * kinda gotta hand-crank this to set up the user profile...
+ * largely the same logic as `look_up_user`.
+ */
+ let looked_up_user = queryer.do_api_get(
+ &format!("{}?screen_name={}", ::USER_LOOKUP_URL, user_handle),
+ &tweeter.app_key,
+ &user_credential
+ ).and_then(|json| tw::user::User::from_json(json));
+
+ let profile_user = match looked_up_user {
+ Ok(user) => user,
+ Err(e) => {
+ display_info.status("Couldn't look up you up - handle and display name are not set. You'll have to manually adjust cache/profile.json.".to_owned());
+ display_info.status(format!("Lookup error: {}", e));
+ tw::user::User::default()
+ }
+ };
+ display_info.status(format!("wtf at auth curr_profile is {:?}", tweeter.curr_profile));
+ if tweeter.curr_profile.is_none() {
+ tweeter.curr_profile = Some(user_handle.to_owned());
+ }
+ tweeter.add_profile(tw::TwitterProfile::new(user_credential, profile_user), Some(user_handle.clone()), display_info);
tweeter.WIP_auth = None;
tweeter.state = tw::AppState::Reconnect(user_handle);
display_info.status("Looks like you authed! Connecting...".to_owned());
diff --git a/src/tw/mod.rs b/src/tw/mod.rs
index 49759e2..0a073c9 100644
--- a/src/tw/mod.rs
+++ b/src/tw/mod.rs
@@ -1042,6 +1042,10 @@ fn handle_twitter_welcome(
match followers_changes {
Ok((my_name, new_following, lost_following, (new_followers, lost_followers))) => {
+ /*
+ * This *will* spam you on login, and isn't very useful.
+ * TODO: present this sanely.
+ *
for user in new_following {
display_info.status(format!("New following! {}", user));
}
@@ -1054,6 +1058,7 @@ fn handle_twitter_welcome(
for user in lost_followers {
display_info.status(format!("{} isn't following anymore", user));
}
+ */
},
Err(e) => {
display_info.status(e);