simplify timeline cache loading, fix lo/hi returns, fix timeline invalidation side-effects missing for some federated actions

This commit is contained in:
kim 2025-04-02 17:25:33 +01:00
commit 53817c23fd
12 changed files with 311 additions and 279 deletions

View file

@ -38,22 +38,6 @@ func (p *Processor) HomeTimelineGet(
*apimodel.PageableResponse,
gtserror.WithCode,
) {
var pageQuery url.Values
var postFilter func(*gtsmodel.Status) (bool, error)
if local {
// Set local = true query.
pageQuery = localOnlyTrue
// Remove any non-local statuses if local-only requested.
postFilter = func(s *gtsmodel.Status) (bool, error) {
return !*s.Local, nil
}
} else {
// Set local = false query.
pageQuery = localOnlyFalse
}
return p.getStatusTimeline(ctx,
// Auth'd
@ -74,7 +58,19 @@ func (p *Processor) HomeTimelineGet(
// page query flag, (this map
// later gets copied before
// any further usage).
pageQuery,
func() url.Values {
var pageQuery url.Values
if local {
// Set local = true query.
pageQuery = localOnlyTrue
} else {
// Set local = false query.
pageQuery = localOnlyFalse
}
return pageQuery
}(),
// Status filter context.
statusfilter.FilterContextHome,
@ -92,9 +88,5 @@ func (p *Processor) HomeTimelineGet(
ok, err := p.visFilter.StatusHomeTimelineable(ctx, requester, s)
return !ok, err
},
// Post-filtering function,
// i.e. filter after caching.
postFilter,
)
}

View file

@ -93,7 +93,7 @@ func (p *Processor) ListTimelineGet(
return p.state.DB.GetListTimeline(ctx, listID, pg)
},
// Pre-filtering function,
// Filtering function,
// i.e. filter before caching.
func(s *gtsmodel.Status) (bool, error) {
@ -101,9 +101,5 @@ func (p *Processor) ListTimelineGet(
ok, err := p.visFilter.StatusHomeTimelineable(ctx, requester, s)
return !ok, err
},
// Post-filtering function,
// i.e. filter after caching.
nil,
)
}

View file

@ -89,10 +89,6 @@ func (p *Processor) publicTimelineGet(
ok, err := p.visFilter.StatusPublicTimelineable(ctx, requester, s)
return !ok, err
},
// Post-filtering function,
// i.e. filter after caching.
nil,
)
}
@ -134,7 +130,7 @@ func (p *Processor) localTimelineGet(
return p.state.DB.GetLocalTimeline(ctx, pg)
},
// Pre-filtering function,
// Filtering function,
// i.e. filter before caching.
func(s *gtsmodel.Status) (bool, error) {
@ -142,9 +138,5 @@ func (p *Processor) localTimelineGet(
ok, err := p.visFilter.StatusPublicTimelineable(ctx, requester, s)
return !ok, err
},
// Post-filtering function,
// i.e. filter after caching.
nil,
)
}

View file

@ -70,8 +70,7 @@ func (p *Processor) getStatusTimeline(
pageQuery url.Values,
filterCtx statusfilter.FilterContext,
loadPage func(*paging.Page) (statuses []*gtsmodel.Status, err error),
preFilter func(*gtsmodel.Status) (bool, error),
postFilter func(*gtsmodel.Status) (bool, error),
filter func(*gtsmodel.Status) (bool, error),
) (
*apimodel.PageableResponse,
gtserror.WithCode,
@ -128,13 +127,9 @@ func (p *Processor) getStatusTimeline(
return p.state.DB.GetStatusesByIDs(ctx, ids)
},
// Pre-filtering function,
// Filtering function,
// i.e. filter before caching.
preFilter,
// Post-filtering function,
// i.e. filter after caching.
postFilter,
filter,
// Frontend API model preparation function.
func(status *gtsmodel.Status) (*apimodel.Status, error) {