summaryrefslogtreecommitdiff
path: root/internal/db/bundb/account.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-01-27 12:10:18 +0100
committerLibravatar GitHub <noreply@github.com>2025-01-27 11:10:18 +0000
commit702d49207fd50f08adfc7411af68ceaa5be82cfb (patch)
treea88ffee4dfca1e90af4ea4bcbbc8c31d403a007e /internal/db/bundb/account.go
parent[chore]: Bump github.com/SherClockHolmes/webpush-go from 1.3.0 to 1.4.0 (#3694) (diff)
downloadgotosocial-702d49207fd50f08adfc7411af68ceaa5be82cfb.tar.xz
[bugfix] Fix top-level posts with a mention being counted as replies when doing `exclude_replies` (#3689)
* [bugfix] Fix top-level posts with a mention being counted as replies * add index for new reply exclusion query
Diffstat (limited to 'internal/db/bundb/account.go')
-rw-r--r--internal/db/bundb/account.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/internal/db/bundb/account.go b/internal/db/bundb/account.go
index 3d85df381..c5f9148a9 100644
--- a/internal/db/bundb/account.go
+++ b/internal/db/bundb/account.go
@@ -899,15 +899,19 @@ func (a *accountDB) GetAccountStatuses(ctx context.Context, accountID string, li
if excludeReplies {
q = q.WhereGroup(" AND ", func(q *bun.SelectQuery) *bun.SelectQuery {
+ // We're excluding replies so
+ // only include posts if they:
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 reply to anything OR
+ Where("? IS NULL", bun.Ident("status.in_reply_to_uri")).
+ // reply to self AND don't mention
+ // anyone (ie., self-reply threads).
+ WhereGroup(" OR ", func(q *bun.SelectQuery) *bun.SelectQuery {
+ q = q.Where("? = ?", bun.Ident("status.in_reply_to_account_id"), accountID)
+ q = whereArrayIsNullOrEmpty(q, bun.Ident("status.mentions"))
+ return q
+ })
})
- // 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 {