[bugfix] Account timeline: exclude self-replies that mention other accounts (#2670)

* Account timeline: exclude self-replies that mention other accounts

* Add index for querying unmentioned statuses

* remove now unused statuses_account_id_id_idx

---------

Co-authored-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
Vyr Cossont 2024-02-27 09:18:40 -08:00 committed by GitHub
commit ad28b9f166
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 212 additions and 1 deletions

View file

@ -604,13 +604,16 @@ func (a *accountDB) GetAccountStatuses(ctx context.Context, accountID string, li
Where("? = ?", bun.Ident("status.account_id"), accountID)
if excludeReplies {
q = q.WhereGroup(" AND ", func(*bun.SelectQuery) *bun.SelectQuery {
q = q.WhereGroup(" AND ", func(q *bun.SelectQuery) *bun.SelectQuery {
return q.
// Do include self replies (threads), but
// don't include replies to other people.
Where("? = ?", bun.Ident("status.in_reply_to_account_id"), accountID).
WhereOr("? IS NULL", bun.Ident("status.in_reply_to_uri"))
})
// Don't include replies that mention other people:
// for example, an account's reply to its own reply to someone else.
q = whereArrayIsNullOrEmpty(q, bun.Ident("status.mentions"))
}
if excludeReblogs {