summaryrefslogtreecommitdiff
path: root/internal/processing/timeline/timeline.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-05-31 17:30:57 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-05-31 17:30:57 +0200
commitfaed35c9388bc28ea0fdfe3aae3b489ca952c006 (patch)
tree989ab37bc3ef1b412ffc509d58939d4f1ac4f5c1 /internal/processing/timeline/timeline.go
parent[feature] make client-side nonce calculation multi-threaded (#4219) (diff)
downloadgotosocial-faed35c9388bc28ea0fdfe3aae3b489ca952c006.tar.xz
[performance] cache mute check results (#4202)
This separates our the user mute handling from the typeconverter code, and creates a new "mutes" filter type (in a similar vein to the visibility filter) subpkg with its own result cache. This is a heavy mix of both chore given that mute calculation shouldn't have been handled in the conversion to frontend API types, and a performance bonus since we don't need to load and calculate so many things each time, just the single result each time with all necessary invalidation handled by database cache hooks. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4202 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/processing/timeline/timeline.go')
-rw-r--r--internal/processing/timeline/timeline.go33
1 files changed, 10 insertions, 23 deletions
diff --git a/internal/processing/timeline/timeline.go b/internal/processing/timeline/timeline.go
index 2eab57195..a86702d42 100644
--- a/internal/processing/timeline/timeline.go
+++ b/internal/processing/timeline/timeline.go
@@ -26,8 +26,8 @@ import (
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
timelinepkg "code.superseriousbusiness.org/gotosocial/internal/cache/timeline"
"code.superseriousbusiness.org/gotosocial/internal/db"
+ "code.superseriousbusiness.org/gotosocial/internal/filter/mutes"
statusfilter "code.superseriousbusiness.org/gotosocial/internal/filter/status"
- "code.superseriousbusiness.org/gotosocial/internal/filter/usermute"
"code.superseriousbusiness.org/gotosocial/internal/filter/visibility"
"code.superseriousbusiness.org/gotosocial/internal/gtserror"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
@@ -48,16 +48,18 @@ var (
)
type Processor struct {
- state *state.State
- converter *typeutils.Converter
- visFilter *visibility.Filter
+ state *state.State
+ converter *typeutils.Converter
+ visFilter *visibility.Filter
+ muteFilter *mutes.Filter
}
-func New(state *state.State, converter *typeutils.Converter, visFilter *visibility.Filter) Processor {
+func New(state *state.State, converter *typeutils.Converter, visFilter *visibility.Filter, muteFilter *mutes.Filter) Processor {
return Processor{
- state: state,
- converter: converter,
- visFilter: visFilter,
+ state: state,
+ converter: converter,
+ visFilter: visFilter,
+ muteFilter: muteFilter,
}
}
@@ -78,7 +80,6 @@ func (p *Processor) getStatusTimeline(
) {
var err error
var filters []*gtsmodel.Filter
- var mutes *usermute.CompiledUserMuteList
if requester != nil {
// Fetch all filters relevant for requesting account.
@@ -89,19 +90,6 @@ func (p *Processor) getStatusTimeline(
err := gtserror.Newf("error getting account filters: %w", err)
return nil, gtserror.NewErrorInternalError(err)
}
-
- // Get a list of all account mutes for requester.
- allMutes, err := p.state.DB.GetAccountMutes(ctx,
- requester.ID,
- nil, // i.e. all
- )
- if err != nil && !errors.Is(err, db.ErrNoEntries) {
- err := gtserror.Newf("error getting account mutes: %w", err)
- return nil, gtserror.NewErrorInternalError(err)
- }
-
- // Compile all account mutes to useable form.
- mutes = usermute.NewCompiledUserMuteList(allMutes)
}
// Ensure we have valid
@@ -148,7 +136,6 @@ func (p *Processor) getStatusTimeline(
requester,
filterCtx,
filters,
- mutes,
)
if err != nil && !errors.Is(err, statusfilter.ErrHideStatus) {
return nil, err