lint: rename ErrHideStatus

This commit is contained in:
Vyr Cossont 2024-03-31 23:16:46 -07:00
parent 5f03f630aa
commit 6f37930963
7 changed files with 12 additions and 12 deletions

View file

@ -22,8 +22,8 @@ import (
"errors"
)
// HideStatus indicates that a status has been filtered and should not be returned at all.
var HideStatus = errors.New("hide status")
// ErrHideStatus indicates that a status has been filtered and should not be returned at all.
var ErrHideStatus = errors.New("hide status")
// FilterContext determines the filters that apply to a given status or list of statuses.
type FilterContext string

View file

@ -99,7 +99,7 @@ outer:
}
apiStatus, err := p.converter.StatusToAPIStatus(ctx, s, requester, custom.FilterContextPublic, filters)
if errors.Is(err, custom.HideStatus) {
if errors.Is(err, custom.ErrHideStatus) {
continue
}
if err != nil {

View file

@ -130,7 +130,7 @@ func (p *Processor) packageTagResponse(
}
apiStatus, err := p.converter.StatusToAPIStatus(ctx, s, requestingAcct, custom.FilterContextPublic, filters)
if errors.Is(err, custom.HideStatus) {
if errors.Is(err, custom.ErrHideStatus) {
continue
}
if err != nil {

View file

@ -567,7 +567,7 @@ func (s *surface) timelineStreamStatusUpdate(
filters []*gtsmodel.Filter,
) error {
apiStatus, err := s.converter.StatusToAPIStatus(ctx, status, account, custom.FilterContextHome, filters)
if errors.Is(err, custom.HideStatus) {
if errors.Is(err, custom.ErrHideStatus) {
// Don't put this status in the stream.
return nil
}

View file

@ -122,7 +122,7 @@ func (t *timeline) prepareXBetweenIDs(ctx context.Context, amount int, behindID
for e, entry := range toPrepare {
prepared, err := t.prepareFunction(ctx, t.timelineID, entry.itemID)
if err != nil {
if errors.Is(err, custom.HideStatus) {
if errors.Is(err, custom.ErrHideStatus) {
// This item has been filtered out by the requesting user's filters.
// Remove it and skip past it.
t.items.data.Remove(e)

View file

@ -682,7 +682,7 @@ func (c *Converter) TagToAPITag(ctx context.Context, t *gtsmodel.Tag, stubHistor
//
// Filter context can be the empty string if these statuses are not being filtered.
//
// If there is a matching "hide" filter, the returned status will be nil with a HideStatus error;
// If there is a matching "hide" filter, the returned status will be nil with a ErrHideStatus error;
// callers need to handle that case by excluding it from results.
func (c *Converter) StatusToAPIStatus(
ctx context.Context,
@ -708,7 +708,7 @@ func (c *Converter) StatusToAPIStatus(
// statusToAPIFilterResults applies filters to a status and returns an API filter result object.
// The result may be nil if no filters matched.
// If the status should not be returned at all, it returns the HideStatus error.
// If the status should not be returned at all, it returns the ErrHideStatus error.
func (c *Converter) statusToAPIFilterResults(
ctx context.Context,
s *gtsmodel.Status,
@ -783,7 +783,7 @@ func (c *Converter) statusToAPIFilterResults(
case gtsmodel.FilterActionHide:
// Don't show this status. Immediate return.
return nil, custom.HideStatus
return nil, custom.ErrHideStatus
}
}
}
@ -1053,7 +1053,7 @@ func (c *Converter) statusToFrontend(
if s.BoostOf != nil {
reblog, err := c.StatusToAPIStatus(ctx, s.BoostOf, requestingAccount, filterContext, filters)
if errors.Is(err, custom.HideStatus) {
if errors.Is(err, custom.ErrHideStatus) {
// If we'd hide the original status, hide the boost.
return nil, err
}

View file

@ -690,7 +690,7 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() {
}`, string(b))
}
// Test that a status which is filtered with a hide filter by the requesting user results in the HideStatus error.
// Test that a status which is filtered with a hide filter by the requesting user results in the ErrHideStatus error.
func (suite *InternalToFrontendTestSuite) TestHideFilteredStatusToFrontend() {
testStatus := suite.testStatuses["admin_account_status_1"]
testStatus.Content += " fnord"
@ -709,7 +709,7 @@ func (suite *InternalToFrontendTestSuite) TestHideFilteredStatusToFrontend() {
custom.FilterContextHome,
requestingAccountFilters,
)
suite.ErrorIs(err, custom.HideStatus)
suite.ErrorIs(err, custom.ErrHideStatus)
}
func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments() {