diff options
Diffstat (limited to 'internal/filter/visibility/status.go')
-rw-r--r-- | internal/filter/visibility/status.go | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/internal/filter/visibility/status.go b/internal/filter/visibility/status.go index be59e800e..a0f971464 100644 --- a/internal/filter/visibility/status.go +++ b/internal/filter/visibility/status.go @@ -104,18 +104,20 @@ func (f *Filter) isStatusVisible( return false, nil } - if util.PtrOrValue(status.PendingApproval, false) { + if util.PtrOrZero(status.PendingApproval) { // Use a different visibility heuristic // for pending approval statuses. - return f.isPendingStatusVisible(ctx, + return isPendingStatusVisible( requester, status, - ) + ), nil } if requester == nil { // Use a different visibility // heuristic for unauthed requests. - return f.isStatusVisibleUnauthed(ctx, status) + return f.isStatusVisibleUnauthed( + ctx, status, + ) } /* @@ -210,45 +212,42 @@ func (f *Filter) isStatusVisible( } } -func (f *Filter) isPendingStatusVisible( - _ context.Context, - requester *gtsmodel.Account, - status *gtsmodel.Status, -) (bool, error) { +// isPendingStatusVisible returns whether a status pending approval is visible to requester. +func isPendingStatusVisible(requester *gtsmodel.Account, status *gtsmodel.Status) bool { if requester == nil { // Any old tom, dick, and harry can't // see pending-approval statuses, // no matter what their visibility. - return false, nil + return false } if status.AccountID == requester.ID { // This is requester's status, // so they can always see it. - return true, nil + return true } if status.InReplyToAccountID == requester.ID { // This status replies to requester, // so they can always see it (else // they can't approve it). - return true, nil + return true } if status.BoostOfAccountID == requester.ID { // This status boosts requester, // so they can always see it. - return true, nil + return true } - // Nobody else can see this. - return false, nil + // Nobody else + // can see this. + return false } -func (f *Filter) isStatusVisibleUnauthed( - ctx context.Context, - status *gtsmodel.Status, -) (bool, error) { +// isStatusVisibleUnauthed returns whether status is visible without any unauthenticated account. +func (f *Filter) isStatusVisibleUnauthed(ctx context.Context, status *gtsmodel.Status) (bool, error) { + // For remote accounts, only show // Public statuses via the web. if status.Account.IsRemote() { @@ -275,8 +274,7 @@ func (f *Filter) isStatusVisibleUnauthed( } } - webVisibility := status.Account.Settings.WebVisibility - switch webVisibility { + switch webvis := status.Account.Settings.WebVisibility; webvis { // public_only: status must be Public. case gtsmodel.VisibilityPublic: @@ -296,7 +294,7 @@ func (f *Filter) isStatusVisibleUnauthed( default: return false, gtserror.Newf( "unrecognized web visibility for account %s: %s", - status.Account.ID, webVisibility, + status.Account.ID, webvis, ) } } |