diff --git a/timeline.go b/timeline.go index faf791b..16c3839 100644 --- a/timeline.go +++ b/timeline.go @@ -173,18 +173,7 @@ func (timeline *timeline) parseTweet(id string) *Tweet { } if tweet.RetweetedStatusIDStr != "" { tw.IsRetweet = true - if retweet, ok := timeline.GlobalObjects.Tweets[tweet.RetweetedStatusIDStr]; ok { - tw.Retweet = Retweet{ - ID: tweet.RetweetedStatusIDStr, - UserID: retweet.UserIDStr, - Username: timeline.GlobalObjects.Users[retweet.UserIDStr].ScreenName, - } - tm, err := time.Parse(time.RubyDate, retweet.CreatedAt) - if err == nil { - tw.Retweet.TimeParsed = tm - tw.Retweet.Timestamp = tm.Unix() - } - } + tw.Retweet = timeline.parseTweet(tweet.RetweetedStatusIDStr) } for _, pinned := range timeline.GlobalObjects.Users[tweet.UserIDStr].PinnedTweetIdsStr { diff --git a/tweets_test.go b/tweets_test.go index 4bd1e8a..1c313a9 100644 --- a/tweets_test.go +++ b/tweets_test.go @@ -96,12 +96,18 @@ func TestGetTweet(t *testing.T) { } func TestRetweet(t *testing.T) { - sample := Retweet{ - ID: "1359151057872580612", - TimeParsed: time.Date(2021, 02, 9, 14, 43, 58, 0, time.FixedZone("UTC", 0)), - Timestamp: 1612881838, - UserID: "773578328498372608", - Username: "TwitterTogether", + sample := &Tweet{ + HTML: "We’ve seen an increase in attacks against Asian communities and individuals around the world. It’s important to know that this isn’t new; throughout history, Asians have experienced violence and exclusion. However, their diverse lived experiences have largely been overlooked.", + ID: "1359151057872580612", + Likes: 6683, + PermanentURL: "https://twitter.com/TwitterTogether/status/1359151057872580612", + Replies: 455, + Retweets: 1495, + Text: "We’ve seen an increase in attacks against Asian communities and individuals around the world. It’s important to know that this isn’t new; throughout history, Asians have experienced violence and exclusion. However, their diverse lived experiences have largely been overlooked.", + TimeParsed: time.Date(2021, 02, 9, 14, 43, 58, 0, time.FixedZone("UTC", 0)), + Timestamp: 1612881838, + UserID: "773578328498372608", + Username: "TwitterTogether", } tweet, err := defaultScraper.GetTweet("1362849141248974853") if err != nil { diff --git a/types.go b/types.go index cde04cf..5bb0f3e 100644 --- a/types.go +++ b/types.go @@ -33,7 +33,7 @@ type ( Photos []string Replies int Retweets int - Retweet Retweet + Retweet *Tweet Text string TimeParsed time.Time Timestamp int64