Add new type of TimelineTimelineModule, the 'profile-conversation'

This commit is contained in:
Alessio 2023-06-22 17:19:46 -03:00
parent 5c6e171ea3
commit a58ebc6988
3 changed files with 29 additions and 7 deletions

View File

@ -427,10 +427,11 @@ func (e APIV2Entry) ToTweetTrove() TweetTrove {
} else if e.Content.EntryType == "TimelineTimelineModule" {
ret := NewTweetTrove()
switch strings.Split(e.EntryID, "-")[0] {
case "homeConversation", "conversationthread":
parts := strings.Split(e.EntryID, "-")
if parts[0] == "homeConversation" || parts[0] == "conversationthread" || strings.Join(parts[0:2], "-") == "profile-conversation" {
// Process it.
// - "homeConversation": conversation thread on a user feed
// - "profile-conversation": conversation thread on a user feed
// - "homeConversation": This looks like it got changed to "profile-conversation"
// - "conversationthread": conversation thread in the replies under a TweetDetail view
for _, item := range e.Content.Items {
if item.Item.ItemContent.ItemType == "TimelineTimelineCursor" {
@ -446,13 +447,11 @@ func (e APIV2Entry) ToTweetTrove() TweetTrove {
}
ret.MergeWith(trove)
}
case "whoToFollow", "TopicsModule", "tweetdetailrelatedtweets":
} else if parts[0] == "whoToFollow" || parts[0] == "TopicsModule" || parts[0] == "tweetdetailrelatedtweets" {
// Ignore "Who to follow", "Topics" and "Related Tweets" modules.
// TODO: maybe we can capture these eventually
log.Debug(fmt.Sprintf("Skipping %s entry", e.EntryID))
default:
} else {
log.Warn("TimelineTimelineModule with unknown EntryID: " + e.EntryID)
}

View File

@ -745,6 +745,28 @@ func TestEntryWithConversationThread(t *testing.T) {
assert.True(is_ok)
}
func TestProfileConversationEntry(t *testing.T) {
assert := assert.New(t)
require := require.New(t)
data, err := os.ReadFile("test_responses/api_v2/user_feed_profile_conversation_module_entry.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, 2)
_, is_ok := trove.Tweets[1671870056953790465]
assert.True(is_ok)
_, is_ok = trove.Users[593289567]
assert.True(is_ok)
_, is_ok = trove.Tweets[1671918780044435456]
assert.True(is_ok)
_, is_ok = trove.Users[358545917]
assert.True(is_ok)
}
// On a Tweet Detail page, there's a thread of replies, and then it says "Show more..." underneath
// to extend the conversation. This is different from the "Show more..." button to load more
// replies to the original tweet!

File diff suppressed because one or more lines are too long