Fix a new bug type where blocked users' tweets can be empty-but-not-tombstoned, or something (not totally sure what this is)

This commit is contained in:
Alessio 2024-11-03 20:07:03 -08:00
parent 631d07c6fc
commit 640ac531e5
3 changed files with 18 additions and 1 deletions

View File

@ -121,3 +121,8 @@ TODO: emoji-rewrite (#webserver)
TODO: windows-session-list (#release, #windows)
- Check that sessions load as @Offline_Twatter instead of @test\Offline_Twatter on Windows
TODO: conversation-thread-missing-tweets
- In a conversation thread (replies under a tweet), if a user is blocked, the tweet response can be empty
- These are just completely invisible on Twitter (render as nothing)
- e.g.: https://x.com/sirbughunter/status/1479540319410696192

View File

@ -463,7 +463,7 @@ func (e *APIV2Entry) ParseID() (string, TweetID) {
func (e APIV2Entry) ToTweetTrove() TweetTrove {
defer func() {
if obj := recover(); obj != nil {
log.Warnf("Panic while decoding entry: %s\n", e.OriginalJSON)
log.Errorf("Panic while decoding entry: %s\n", e.OriginalJSON)
panic(obj)
}
}()
@ -499,6 +499,8 @@ func (e APIV2Entry) ToTweetTrove() TweetTrove {
if errors.Is(err, ErrorIsTombstone) {
// TODO: do something with tombstones in replies to a Tweet Detail
// For now, just ignore tombstones in the replies
} else if errors.Is(err, ERR_NO_TWEET) {
// TODO: handle this; some information can be recovered, we're just throwing it out
} else if err != nil {
panic(err)
}

View File

@ -700,6 +700,16 @@ func TestAPIV2ConversationThreadWithTombstones(t *testing.T) {
assert.Len(trove.Retweets, 0)
}
func TestAPIV2ConversationThreadEntryWithEmptyTweet(t *testing.T) {
data, err := os.ReadFile("test_responses/api_v2/conversation_thread_entry_with_empty_tweet_because_user_is_blocked.json")
require.NoError(t, err)
var resp APIV2Entry
err = json.Unmarshal(data, &resp)
require.NoError(t, err)
_ = resp.ToTweetTrove()
}
func TestTweetWithWarning(t *testing.T) {
assert := assert.New(t)
data, err := os.ReadFile("test_responses/api_v2/tweet_with_warning.json")