mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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>
This commit is contained in:
@@ -25,7 +25,6 @@ import (
|
||||
|
||||
apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model"
|
||||
statusfilter "code.superseriousbusiness.org/gotosocial/internal/filter/status"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/gtscontext"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/gtserror"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
|
||||
)
|
||||
@@ -291,26 +290,8 @@ func (p *Processor) ContextGet(
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
// Retrieve mutes as they affect
|
||||
// what should be shown to requester.
|
||||
mutes, err := p.state.DB.GetAccountMutes(
|
||||
// No need to populate mutes,
|
||||
// IDs are enough here.
|
||||
gtscontext.SetBarebones(ctx),
|
||||
requester.ID,
|
||||
nil, // No paging - get all.
|
||||
)
|
||||
if err != nil {
|
||||
err = gtserror.Newf(
|
||||
"couldn't retrieve mutes for account %s: %w",
|
||||
requester.ID, err,
|
||||
)
|
||||
return nil, gtserror.NewErrorInternalError(err)
|
||||
}
|
||||
|
||||
// Retrieve the full thread context.
|
||||
threadContext, errWithCode := p.contextGet(
|
||||
ctx,
|
||||
threadContext, errWithCode := p.contextGet(ctx,
|
||||
requester,
|
||||
targetStatusID,
|
||||
)
|
||||
@@ -326,7 +307,6 @@ func (p *Processor) ContextGet(
|
||||
threadContext.ancestors,
|
||||
statusfilter.FilterContextThread,
|
||||
filters,
|
||||
mutes,
|
||||
)
|
||||
|
||||
// Convert and filter the thread context descendants
|
||||
@@ -335,7 +315,6 @@ func (p *Processor) ContextGet(
|
||||
threadContext.descendants,
|
||||
statusfilter.FilterContextThread,
|
||||
filters,
|
||||
mutes,
|
||||
)
|
||||
|
||||
return &apiContext, nil
|
||||
@@ -352,8 +331,8 @@ func (p *Processor) WebContextGet(
|
||||
targetStatusID string,
|
||||
) (*apimodel.WebThreadContext, gtserror.WithCode) {
|
||||
// Retrieve the internal thread context.
|
||||
iCtx, errWithCode := p.contextGet(
|
||||
ctx,
|
||||
iCtx, errWithCode := p.contextGet(ctx,
|
||||
|
||||
nil, // No authed requester.
|
||||
targetStatusID,
|
||||
)
|
||||
|
Reference in New Issue
Block a user