diff options
| author | 2025-06-16 13:12:48 +0200 | |
|---|---|---|
| committer | 2025-06-16 13:12:48 +0200 | |
| commit | b1c0eca1d82f4a63c7a8c8cadec3cc7d59564cf1 (patch) | |
| tree | a499b0f80e54372e1370d45a8eebac3fd2ad5821 | |
| parent | [feature] Outgoing federation of avatar/header descriptions (#4270) (diff) | |
| download | gotosocial-b1c0eca1d82f4a63c7a8c8cadec3cc7d59564cf1.tar.xz | |
[bugfix] improved mute checking for boosted statuses (#4276)
This unwraps and follows the boosted status to do a full mute check on the original.
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4276
Reviewed-by: tobi <kipvandenbos@noreply.codeberg.org>
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
| -rw-r--r-- | internal/filter/mutes/status.go | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/internal/filter/mutes/status.go b/internal/filter/mutes/status.go index e2ef1e5a5..04789d798 100644 --- a/internal/filter/mutes/status.go +++ b/internal/filter/mutes/status.go @@ -232,6 +232,44 @@ func (f *Filter) getStatusRelatedUserMutes( return nil, nil } + // Preallocate a slice of worst possible case no. user mutes. + mutes := make([]*gtsmodel.UserMute, 0, 2+len(status.Mentions)) + + // Check if status is boost. + if status.BoostOfID != "" { + if status.BoostOf == nil { + var err error + + // Ensure original status is loaded on boost. + status.BoostOf, err = f.state.DB.GetStatusByID( + gtscontext.SetBarebones(ctx), + status.BoostOfID, + ) + if err != nil { + return nil, gtserror.Newf("error getting boosted status of %s: %w", status.URI, err) + } + } + + // Look for mute against booster. + mute, err := f.state.DB.GetMute( + gtscontext.SetBarebones(ctx), + requester.ID, + status.AccountID, + ) + if err != nil && !errors.Is(err, db.ErrNoEntries) { + return nil, gtserror.Newf("db error getting status author mute: %w", err) + } + + if mute != nil { + // Append author mute to total. + mutes = append(mutes, mute) + } + + // From here look at details + // for original boosted status. + status = status.BoostOf + } + if !status.MentionsPopulated() { var err error @@ -242,9 +280,6 @@ func (f *Filter) getStatusRelatedUserMutes( } } - // Preallocate a slice of worst possible case no. user mutes. - mutes := make([]*gtsmodel.UserMute, 0, 2+len(status.Mentions)) - // Look for mute against author. mute, err := f.state.DB.GetMute( gtscontext.SetBarebones(ctx), @@ -260,23 +295,6 @@ func (f *Filter) getStatusRelatedUserMutes( mutes = append(mutes, mute) } - if status.BoostOfAccountID != "" { - // Look for mute against boost author. - mute, err := f.state.DB.GetMute( - gtscontext.SetBarebones(ctx), - requester.ID, - status.AccountID, - ) - if err != nil && !errors.Is(err, db.ErrNoEntries) { - return nil, gtserror.Newf("db error getting boost author mute: %w", err) - } - - if mute != nil { - // Append author mute to total. - mutes = append(mutes, mute) - } - } - for _, mention := range status.Mentions { // Look for mute against any target mentions. if mention.TargetAccountID != requester.ID { |
