Fix crashing on non-timeline-module composer button entries
This commit is contained in:
parent
e319dc1988
commit
90f453c207
@ -492,7 +492,7 @@ func (e APIV2Entry) ToTweetTrove() TweetTrove {
|
||||
continue
|
||||
}
|
||||
if item.Item.ItemContent.ItemType == "TimelineTweetComposer" {
|
||||
// Composer button
|
||||
// Composer button (timeline module version)
|
||||
continue
|
||||
}
|
||||
trove, err := item.Item.ItemContent.TweetResults.ToTweetTrove()
|
||||
@ -518,6 +518,10 @@ func (e APIV2Entry) ToTweetTrove() TweetTrove {
|
||||
// TODO: user feed tombstone entries
|
||||
return NewTweetTrove()
|
||||
}
|
||||
if e.Content.ItemContent.ItemType == "TimelineTweetComposer" {
|
||||
// Composer button (regular thread version)
|
||||
return NewTweetTrove()
|
||||
}
|
||||
if strings.Split(e.EntryID, "-")[0] == "messageprompt" {
|
||||
return NewTweetTrove()
|
||||
}
|
||||
|
@ -976,7 +976,7 @@ func TestTweetWithImplicitQuotedTombstone(t *testing.T) {
|
||||
assert.Equal(t2.TombstoneType, "unavailable")
|
||||
}
|
||||
|
||||
func TestNoFailOnComposerEntry(t *testing.T) {
|
||||
func TestNoFailOnComposerEntryInTimelineModule(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
data, err := os.ReadFile("test_responses/api_v2/composer_entry_item.json")
|
||||
@ -988,3 +988,15 @@ func TestNoFailOnComposerEntry(t *testing.T) {
|
||||
trove := entry_result.ToTweetTrove()
|
||||
assert.Len(trove.Tweets, 0)
|
||||
}
|
||||
func TestNoFailOnComposerEntryInRegularThread(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
require := require.New(t)
|
||||
data, err := os.ReadFile("test_responses/api_v2/composer_entry_item_non_module.json")
|
||||
require.NoError(err)
|
||||
var entry_result APIV2Entry
|
||||
err = json.Unmarshal(data, &entry_result)
|
||||
require.NoError(err)
|
||||
|
||||
trove := entry_result.ToTweetTrove()
|
||||
assert.Len(trove.Tweets, 0)
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
{"entryId":"tweetcomposer--1","sortIndex":"7407168758699622302","content":{"entryType":"TimelineTimelineItem","__typename":"TimelineTimelineItem","itemContent":{"itemType":"TimelineTweetComposer","__typename":"TimelineTweetComposer","composerDisplayType":"SelfThread","composerButtonText":"Add another post","composerButtonUrl":{"url":"twitter://post?in_reply_to_status_id=1816203278155153495","urlType":"DeepLink"}}}}
|
Loading…
x
Reference in New Issue
Block a user