diff --git a/internal/processing/timeline/home.go b/internal/processing/timeline/home.go index bfefb5bb5..cd8aa7de1 100644 --- a/internal/processing/timeline/home.go +++ b/internal/processing/timeline/home.go @@ -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, ) } diff --git a/internal/processing/timeline/list.go b/internal/processing/timeline/list.go index 18be9e23f..10a7bb388 100644 --- a/internal/processing/timeline/list.go +++ b/internal/processing/timeline/list.go @@ -106,5 +106,9 @@ func (p *Processor) ListTimelineGet( } return !ok }, + + // Post filtering funtion, + // i.e. filter after caching. + nil, ) } diff --git a/internal/processing/timeline/public.go b/internal/processing/timeline/public.go index 8a654a9e4..0e675da14 100644 --- a/internal/processing/timeline/public.go +++ b/internal/processing/timeline/public.go @@ -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, ) } diff --git a/internal/processing/timeline/tag.go b/internal/processing/timeline/tag.go index b752a6731..685bac376 100644 --- a/internal/processing/timeline/tag.go +++ b/internal/processing/timeline/tag.go @@ -105,6 +105,10 @@ func (p *Processor) TagTimelineGet( } return !ok }, + + // Post filtering funtion, + // i.e. filter after caching. + nil, ) } diff --git a/internal/processing/timeline/timeline.go b/internal/processing/timeline/timeline.go index 7a49e58f2..54ea2cccd 100644 --- a/internal/processing/timeline/timeline.go +++ b/internal/processing/timeline/timeline.go @@ -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,