mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 15:52:26 -05:00
ensure we filter home timeline statuses on local only
This commit is contained in:
parent
7cd2269cde
commit
c92bb83298
5 changed files with 46 additions and 14 deletions
|
|
@ -40,6 +40,20 @@ func (p *Processor) HomeTimelineGet(
|
|||
*apimodel.PageableResponse,
|
||||
gtserror.WithCode,
|
||||
) {
|
||||
|
||||
var pageQuery url.Values
|
||||
var postFilter func(*gtsmodel.Status) bool
|
||||
if local {
|
||||
// Set local = true query.
|
||||
pageQuery = localOnlyTrue
|
||||
postFilter = func(s *gtsmodel.Status) bool {
|
||||
return *s.Local
|
||||
}
|
||||
} else {
|
||||
// Set local = false query.
|
||||
pageQuery = localOnlyFalse
|
||||
postFilter = nil
|
||||
}
|
||||
return p.getStatusTimeline(ctx,
|
||||
|
||||
// Auth'd
|
||||
|
|
@ -60,19 +74,7 @@ func (p *Processor) HomeTimelineGet(
|
|||
// page query flag, (this map
|
||||
// later gets copied before
|
||||
// any further usage).
|
||||
func() url.Values {
|
||||
var pageQuery url.Values
|
||||
|
||||
if local {
|
||||
// Set local = true query.
|
||||
pageQuery = localOnlyTrue
|
||||
} else {
|
||||
// Set local = false query.
|
||||
pageQuery = localOnlyFalse
|
||||
}
|
||||
|
||||
return pageQuery
|
||||
}(),
|
||||
pageQuery,
|
||||
|
||||
// Status filter context.
|
||||
statusfilter.FilterContextHome,
|
||||
|
|
@ -82,7 +84,7 @@ func (p *Processor) HomeTimelineGet(
|
|||
return p.state.DB.GetHomeTimeline(ctx, requester.ID, pg)
|
||||
},
|
||||
|
||||
// Pre-filtering function,
|
||||
// Filtering function,
|
||||
// i.e. filter before caching.
|
||||
func(s *gtsmodel.Status) bool {
|
||||
|
||||
|
|
@ -93,5 +95,9 @@ func (p *Processor) HomeTimelineGet(
|
|||
}
|
||||
return !ok
|
||||
},
|
||||
|
||||
// Post filtering funtion,
|
||||
// i.e. filter after caching.
|
||||
postFilter,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,5 +106,9 @@ func (p *Processor) ListTimelineGet(
|
|||
}
|
||||
return !ok
|
||||
},
|
||||
|
||||
// Post filtering funtion,
|
||||
// i.e. filter after caching.
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@ func (p *Processor) publicTimelineGet(
|
|||
}
|
||||
return !ok
|
||||
},
|
||||
|
||||
// Post filtering funtion,
|
||||
// i.e. filter after caching.
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -149,5 +153,9 @@ func (p *Processor) localTimelineGet(
|
|||
}
|
||||
return !ok
|
||||
},
|
||||
|
||||
// Post filtering funtion,
|
||||
// i.e. filter after caching.
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,10 @@ func (p *Processor) TagTimelineGet(
|
|||
}
|
||||
return !ok
|
||||
},
|
||||
|
||||
// Post filtering funtion,
|
||||
// i.e. filter after caching.
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ func (p *Processor) getStatusTimeline(
|
|||
filterCtx statusfilter.FilterContext,
|
||||
loadPage func(*paging.Page) (statuses []*gtsmodel.Status, err error),
|
||||
filter func(*gtsmodel.Status) (delete bool),
|
||||
postFilter func(*gtsmodel.Status) (remove bool),
|
||||
) (
|
||||
*apimodel.PageableResponse,
|
||||
gtserror.WithCode,
|
||||
|
|
@ -133,6 +134,15 @@ func (p *Processor) getStatusTimeline(
|
|||
|
||||
// Frontend API model preparation function.
|
||||
func(status *gtsmodel.Status) (*apimodel.Status, error) {
|
||||
|
||||
// Check if status needs filtering OUTSIDE of caching stage.
|
||||
// TODO: this will be moved to separate postFilter hook when
|
||||
// all filtering has been removed from the type converter.
|
||||
if postFilter != nil && postFilter(status) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Finally, pass status to get converted to API model.
|
||||
apiStatus, err := p.converter.StatusToAPIStatus(ctx,
|
||||
status,
|
||||
requester,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue