aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-16 23:24:52 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-17 00:11:56 -0700
commit2ab8a00fdd6a8e9386d08c83cb7318ceb3c3c31a (patch)
tree5b3c3a33afa92ed11fe62cf04abcf8553e34aa4b
parent7added395187dda6b295a9c8b4d605983c1ec68a (diff)
render quoted tweets
double-post bug if you are the author of the quoting tweet because you see the event AND your tweet in your feed
-rw-r--r--src/display/mod.rs6
-rw-r--r--src/tw/events.rs8
-rw-r--r--src/tw/mod.rs4
3 files changed, 17 insertions, 1 deletions
diff --git a/src/display/mod.rs b/src/display/mod.rs
index e66ac77..3a48454 100644
--- a/src/display/mod.rs
+++ b/src/display/mod.rs
@@ -34,6 +34,12 @@ pub trait Render {
impl Render for tw::events::Event {
fn render(self, tweeter: &::tw::TwitterCache) {
match self {
+ tw::events::Event::Quoted { user_id, twete_id } => {
+ println!("---------------------------------");
+ let user = tweeter.retrieve_user(&user_id).unwrap();
+ println!(" quoted_tweet : {} (@{})", user.name, user.handle);
+ render_twete(&twete_id, tweeter);
+ }
tw::events::Event::Deleted { user_id, twete_id } => {
if let Some(handle) = tweeter.retrieve_user(&user_id).map(|x| &x.handle) {
if let Some(_tweet) = tweeter.retrieve_tweet(&twete_id) {
diff --git a/src/tw/events.rs b/src/tw/events.rs
index 0541b0a..c26a840 100644
--- a/src/tw/events.rs
+++ b/src/tw/events.rs
@@ -6,6 +6,7 @@ pub enum Event {
Fav_RT { user_id: String, twete_id: String },
Fav { user_id: String, twete_id: String },
Unfav { user_id: String, twete_id: String },
+ Quoted { user_id: String, twete_id: String },
Followed { user_id: String },
Unfollowed { user_id: String }
}
@@ -35,9 +36,14 @@ impl Event {
user_id: structure["source"]["id_str"].as_str().unwrap().to_owned(),
twete_id: structure["target_object"]["id_str"].as_str().unwrap().to_owned()
}),
+ &"quoted_tweet" => Some(Event::Quoted {
+ user_id: structure["source"]["id_str"].as_str().unwrap().to_owned(),
+ twete_id: structure["target_object"]["id_str"].as_str().unwrap().to_owned()
+ }),
+// &"list_member_added" =>
+// what about removed?
// &"blocked" => Blocked { },
// &"unblocked" => Unblocked { },
-// &"quoted_tweet" => ???,
e => { println!("unrecognized event: {}", e); None }
}
}
diff --git a/src/tw/mod.rs b/src/tw/mod.rs
index 9433e45..710bf59 100644
--- a/src/tw/mod.rs
+++ b/src/tw/mod.rs
@@ -241,6 +241,10 @@ impl TwitterCache {
pub fn cache_api_event(&mut self, json: serde_json::Map<String, serde_json::Value>, mut queryer: &mut ::Queryer) {
/* don't really care to hold on to who fav, unfav, ... when, just pick targets out. */
match json.get("event").and_then(|x| x.as_str()) {
+ Some("quoted_tweet") => {
+ self.cache_api_tweet(json["target_object"].clone());
+ self.cache_api_user(json["source"].clone());
+ },
Some("favorite") => {
self.cache_api_tweet(json["target_object"].clone());
self.cache_api_user(json["source"].clone());