summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-12-01 15:43:38 +0100
committerLibravatar tobi <tobi.smethurst@protonmail.com>2026-01-22 13:26:46 +0100
commit2e697a7f989ef95c9be544928a61d4650b4ae337 (patch)
treefacebdf7e899927ae95853586d18171365ba298a /internal
parent[bugfix] potential race condition on status unboost (#4596) (diff)
downloadgotosocial-2e697a7f989ef95c9be544928a61d4650b4ae337.tar.xz
[bugfix] don't apply visibility / status filtering when requesting your own account statuses (#4597)
# Description This updates our account statuses function to only apply filtering when requesting accounts other than your own. This should prevent confusing situations like https://codeberg.org/superseriousbusiness/gotosocial/issues/4594 occurring. ## Checklist - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [x] I/we have not used so-called 'AI' to create the proposed changes. - [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [x] I/we have commented the added code, particularly in hard-to-understand areas. - [ ] I/we have made any necessary changes to documentation. - [ ] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4597 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/filter/mutes/status.go6
-rw-r--r--internal/filter/status/status.go6
-rw-r--r--internal/filter/visibility/status.go14
-rw-r--r--internal/processing/account/statuses.go23
4 files changed, 34 insertions, 15 deletions
diff --git a/internal/filter/mutes/status.go b/internal/filter/mutes/status.go
index befe07e88..b0cdc3400 100644
--- a/internal/filter/mutes/status.go
+++ b/internal/filter/mutes/status.go
@@ -165,6 +165,12 @@ func (f *Filter) getStatusMuteDetails(
next = inReplyTo
}
+ // If requester is owner of the status,
+ // don't mark it as muted (hidden) to them.
+ if requester.ID == status.AccountID {
+ details.mute = false
+ }
+
return details, nil
}
diff --git a/internal/filter/status/status.go b/internal/filter/status/status.go
index 572f669d5..d2d18fa21 100644
--- a/internal/filter/status/status.go
+++ b/internal/filter/status/status.go
@@ -160,6 +160,12 @@ func (f *Filter) getStatusFilterResults(
return results, nil
}
+ // Shortcut to check up-front for owner
+ // of their own status, i.e. no filtering.
+ if status.AccountID == requester.ID {
+ return results, nil
+ }
+
// Check if status is boost.
if status.BoostOfID != "" {
if status.BoostOf == nil {
diff --git a/internal/filter/visibility/status.go b/internal/filter/visibility/status.go
index c46fd369c..f5c236437 100644
--- a/internal/filter/visibility/status.go
+++ b/internal/filter/visibility/status.go
@@ -96,6 +96,11 @@ func (f *Filter) isStatusVisible(
return false, gtserror.Newf("error populating status %s: %w", status.ID, err)
}
+ // Shortcut to check up-front for owner of their own status.
+ if requester != nil && status.AccountID == requester.ID {
+ return true, nil
+ }
+
// Check whether status accounts are visible to the requester.
acctsVisible, err := f.areStatusAccountsVisible(ctx, requester, status)
if err != nil {
@@ -113,8 +118,8 @@ func (f *Filter) isStatusVisible(
}
if requester == nil {
- // Use a different visibility
- // heuristic for unauthed requests.
+ // Use different visibility heuristics
+ // when dealing with unauthed requests.
return f.isStatusVisibleUnauthed(status), nil
}
@@ -140,11 +145,6 @@ func (f *Filter) isStatusVisible(
is of visibility followers-only or below.
*/
- if requester.ID == status.AccountID {
- // Author can always see their own status.
- return true, nil
- }
-
if status.MentionsAccount(requester.ID) {
// Status mentions the requesting account.
return true, nil
diff --git a/internal/processing/account/statuses.go b/internal/processing/account/statuses.go
index 870019f41..820feb58e 100644
--- a/internal/processing/account/statuses.go
+++ b/internal/processing/account/statuses.go
@@ -35,7 +35,7 @@ import (
// target account, filtered by visibility according to the requesting account.
func (p *Processor) StatusesGet(
ctx context.Context,
- requestingAccount *gtsmodel.Account,
+ requester *gtsmodel.Account,
targetAccountID string,
limit int,
excludeReplies bool,
@@ -46,8 +46,8 @@ func (p *Processor) StatusesGet(
mediaOnly bool,
publicOnly bool,
) (*apimodel.PageableResponse, gtserror.WithCode) {
- if requestingAccount != nil {
- blocked, err := p.state.DB.IsEitherBlocked(ctx, requestingAccount.ID, targetAccountID)
+ if requester != nil {
+ blocked, err := p.state.DB.IsEitherBlocked(ctx, requester.ID, targetAccountID)
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
@@ -90,17 +90,20 @@ func (p *Processor) StatusesGet(
prevMinIDValue = statuses[0].ID
)
- // Filtering + serialization process is the same for
+ // Filtering + serialization process is same for
// both pinned status queries and 'normal' ones.
- filtered, err := p.visFilter.StatusesVisible(ctx, requestingAccount, statuses)
+ filtered, err := p.visFilter.StatusesVisible(ctx,
+ requester,
+ statuses,
+ )
if err != nil {
return nil, gtserror.NewErrorInternalError(err)
}
for _, status := range filtered {
- // ...
+ // Apply status filtering in account context to each of the statuses.
filtered, hide, err := p.statusFilter.StatusFilterResultsInContext(ctx,
- requestingAccount,
+ requester,
status,
gtsmodel.FilterContextAccount,
)
@@ -115,7 +118,10 @@ func (p *Processor) StatusesGet(
}
// Convert filtered statuses to API statuses.
- item, err := p.converter.StatusToAPIStatus(ctx, status, requestingAccount)
+ item, err := p.converter.StatusToAPIStatus(ctx,
+ status,
+ requester,
+ )
if err != nil {
log.Errorf(ctx, "error convering to api status: %v", err)
continue
@@ -124,6 +130,7 @@ func (p *Processor) StatusesGet(
// Set any filter results.
item.Filtered = filtered
+ // Append item to ret slice.
items = append(items, item)
}