From 0cf10324137f8fb737d44d675fdbbf0cce49005b Mon Sep 17 00:00:00 2001 From: aska Date: Mon, 4 Apr 2016 21:43:26 +0900 Subject: [PATCH 1/3] Add streaming event for delete direct message ```json // sample {"delete":{"direct_message":{"id":716968737170006021,"id_str":"716968737170006021","user_id":69886580}}} ``` --- streaming.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/streaming.go b/streaming.go index ae62649..68a4197 100644 --- a/streaming.go +++ b/streaming.go @@ -19,6 +19,17 @@ const ( // messages +type DirectMessageDeletionNotice struct { + Id int64 `json:"id"` + IdStr string `json:"id_str"` + UserId int64 `json:"user_id"` +} +type directMessageDeletionNotice struct { + Delete *struct { + DirectMessage *DirectMessageDeletionNotice `json:"direct_message"` + } `json:"delete"` +} + type StatusDeletionNotice struct { Id int64 `json:"id"` IdStr string `json:"id_str"` @@ -171,6 +182,8 @@ func jsonToKnownType(j []byte) interface{} { // TODO: DRY if o := new(Tweet); jsonAsStruct(j, "/source", &o) { return *o + } else if o := new(directMessageDeletionNotice); jsonAsStruct(j, "/delete/direct_message", &o) { + return *o.Delete.DirectMessage } else if o := new(statusDeletionNotice); jsonAsStruct(j, "/delete", &o) { return *o.Delete.Status } else if o := new(locationDeletionNotice); jsonAsStruct(j, "/scrub_geo", &o) { From 501fca9875295e78b69607633bdcd2c4215586dc Mon Sep 17 00:00:00 2001 From: Shinichiro Aska Date: Tue, 5 Apr 2016 01:34:27 +0900 Subject: [PATCH 2/3] Fix import path --- example_test.go | 2 +- oembed_test.go | 2 +- twitter_test.go | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/example_test.go b/example_test.go index 0c8f1f9..89476b7 100644 --- a/example_test.go +++ b/example_test.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - anaconda "." + "github.com/ChimeraCoder/anaconda" ) // Initialize an client library for a given user. diff --git a/oembed_test.go b/oembed_test.go index a3cf89b..8032929 100644 --- a/oembed_test.go +++ b/oembed_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - anaconda "." + "github.com/ChimeraCoder/anaconda" ) func TestOEmbed(t *testing.T) { diff --git a/twitter_test.go b/twitter_test.go index 999e002..fb66ffa 100644 --- a/twitter_test.go +++ b/twitter_test.go @@ -15,7 +15,7 @@ import ( "testing" "time" - anaconda "." + "github.com/ChimeraCoder/anaconda" ) var CONSUMER_KEY = os.Getenv("CONSUMER_KEY") @@ -201,10 +201,9 @@ func Test_GetTweet(t *testing.T) { expectedEntities := anaconda.Entities{Hashtags: []struct { Indices []int Text string - }{struct { - Indices []int - Text string - }{Indices: []int{86, 93}, Text: "golang"}}, Urls: []struct { + }{ + + {Indices: []int{86, 93}, Text: "golang"}}, Urls: []struct { Indices []int Url string Display_url string @@ -215,7 +214,7 @@ func Test_GetTweet(t *testing.T) { Screen_name string Id int64 Id_str string - }{}, Media: []anaconda.EntityMedia{anaconda.EntityMedia{ + }{}, Media: []anaconda.EntityMedia{{ Id: 303777106628841472, Id_str: "303777106628841472", Media_url: "http://pbs.twimg.com/media/BDc7q0OCEAAoe2C.jpg", From 3c6ba2f1057d805fc1f381393e9ceefe9c4c1670 Mon Sep 17 00:00:00 2001 From: aska Date: Tue, 5 Apr 2016 17:16:42 +0900 Subject: [PATCH 3/3] Add QuotedStatus --- tweet.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tweet.go b/tweet.go index 65f26c9..883cb3c 100644 --- a/tweet.go +++ b/tweet.go @@ -24,6 +24,7 @@ type Tweet struct { Lang string `json:"lang"` Place Place `json:"place"` PossiblySensitive bool `json:"possibly_sensitive"` + QuotedStatus *Tweet `json:"quoted_status"` RetweetCount int `json:"retweet_count"` Retweeted bool `json:"retweeted"` RetweetedStatus *Tweet `json:"retweeted_status"`