Fix 'user followed you' notifications sometimes parsing as 'new recommended post' notifications

This commit is contained in:
Alessio 2024-10-23 22:40:43 -07:00
parent 859431f012
commit e319dc1988
3 changed files with 24 additions and 16 deletions

View File

@ -131,6 +131,9 @@ func (t *TweetResponse) ToTweetTroveAsNotifications(current_user_id UserID) (Twe
} }
notification.UserID = current_user_id notification.UserID = current_user_id
notification.SortIndex = entry.SortIndex notification.SortIndex = entry.SortIndex
// Determine a notification type if there isn't one yet
if notification.Type == 0 {
if strings.Contains(entry.Content.Item.ClientEventInfo.Element, "replied") { if strings.Contains(entry.Content.Item.ClientEventInfo.Element, "replied") {
notification.Type = NOTIFICATION_TYPE_REPLY notification.Type = NOTIFICATION_TYPE_REPLY
} else if strings.Contains(entry.Content.Item.ClientEventInfo.Element, "recommended") { } else if strings.Contains(entry.Content.Item.ClientEventInfo.Element, "recommended") {
@ -147,6 +150,7 @@ func (t *TweetResponse) ToTweetTroveAsNotifications(current_user_id UserID) (Twe
delete(ret.Notifications, notification.ID) delete(ret.Notifications, notification.ID)
continue continue
} }
}
if strings.Contains(entry.Content.Item.ClientEventInfo.Element, "multiple") { if strings.Contains(entry.Content.Item.ClientEventInfo.Element, "multiple") {
notification.HasDetail = true notification.HasDetail = true

View File

@ -129,6 +129,10 @@ func TestParseNotificationsPage(t *testing.T) {
assert.True(is_ok) assert.True(is_ok)
assert.True(notif12.HasDetail) assert.True(notif12.HasDetail)
notif13, is_ok := tweet_trove.Notifications["FDzeDIfVUAIAAAABiJONcrvLSfVQeHf9GlI"]
assert.True(is_ok)
assert.Equal(NOTIFICATION_TYPE_FOLLOW, notif13.Type)
// TODO: communities // TODO: communities
// notif12, is_ok := tweet_trove.Notifications["FDzeDIfVUAIAAAABiJONco_yJRHPBNsDH88"] // notif12, is_ok := tweet_trove.Notifications["FDzeDIfVUAIAAAABiJONco_yJRHPBNsDH88"]
// assert.True(is_ok) // assert.True(is_ok)

File diff suppressed because one or more lines are too long