From 4f2aa792b33fdd5fb4b22dec813b3668d7190522 Mon Sep 17 00:00:00 2001 From: kim Date: Tue, 1 Jul 2025 16:00:04 +0200 Subject: [performance] add statusfilter cache to cache calculated status filtering results (#4303) this adds another 'filter' type cache, similar to the visibility and mute caches, to cache the results of status filtering checks. for the moment this keeps all the check calls themselves within the frontend typeconversion code, but i may move this out of the typeconverter in a future PR (also removing the ErrHideStatus means of propagating a hidden status). also tweaks some of the cache invalidation hooks to not make unnecessary calls. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4303 Co-authored-by: kim Co-committed-by: kim --- internal/processing/timeline/notification.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'internal/processing/timeline/notification.go') diff --git a/internal/processing/timeline/notification.go b/internal/processing/timeline/notification.go index 143145bb9..784b2b824 100644 --- a/internal/processing/timeline/notification.go +++ b/internal/processing/timeline/notification.go @@ -27,11 +27,11 @@ import ( apimodel "code.superseriousbusiness.org/gotosocial/internal/api/model" apiutil "code.superseriousbusiness.org/gotosocial/internal/api/util" "code.superseriousbusiness.org/gotosocial/internal/db" - "code.superseriousbusiness.org/gotosocial/internal/filter/status" "code.superseriousbusiness.org/gotosocial/internal/gtserror" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" "code.superseriousbusiness.org/gotosocial/internal/log" "code.superseriousbusiness.org/gotosocial/internal/paging" + "code.superseriousbusiness.org/gotosocial/internal/typeutils" "code.superseriousbusiness.org/gotosocial/internal/util" ) @@ -59,12 +59,6 @@ func (p *Processor) NotificationsGet( return util.EmptyPageableResponse(), nil } - filters, err := p.state.DB.GetFiltersByAccountID(ctx, requester.ID) - if err != nil { - err = gtserror.Newf("error getting account %s filters: %w", requester.ID, err) - return nil, gtserror.NewErrorInternalError(err) - } - var ( items = make([]interface{}, 0, count) @@ -115,9 +109,9 @@ func (p *Processor) NotificationsGet( } } - item, err := p.converter.NotificationToAPINotification(ctx, n, filters) + item, err := p.converter.NotificationToAPINotification(ctx, n, true) if err != nil { - if !errors.Is(err, status.ErrHideStatus) { + if !errors.Is(err, typeutils.ErrHideStatus) { log.Debugf(ctx, "skipping notification %s because it couldn't be converted to its api representation: %s", n.ID, err) } continue @@ -160,7 +154,7 @@ func (p *Processor) NotificationGet(ctx context.Context, account *gtsmodel.Accou // or mute checking for a notification directly // fetched by ID. only from timelines etc. - apiNotif, err := p.converter.NotificationToAPINotification(ctx, notif, nil) + apiNotif, err := p.converter.NotificationToAPINotification(ctx, notif, false) if err != nil { err := gtserror.Newf("error converting to api model: %w", err) return nil, gtserror.WrapWithCode(http.StatusInternalServerError, err) -- cgit v1.2.3