diff options
| author | 2025-12-01 15:43:38 +0100 | |
|---|---|---|
| committer | 2026-01-22 13:26:46 +0100 | |
| commit | 2e697a7f989ef95c9be544928a61d4650b4ae337 (patch) | |
| tree | facebdf7e899927ae95853586d18171365ba298a /internal/processing/account | |
| parent | [bugfix] potential race condition on status unboost (#4596) (diff) | |
| download | gotosocial-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/processing/account')
| -rw-r--r-- | internal/processing/account/statuses.go | 23 |
1 files changed, 15 insertions, 8 deletions
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) } |
