summaryrefslogtreecommitdiff
path: root/internal/processing/filters/v2
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-07-01 16:00:04 +0200
committerLibravatar kim <gruf@noreply.codeberg.org>2025-07-01 16:00:04 +0200
commit4f2aa792b33fdd5fb4b22dec813b3668d7190522 (patch)
tree1148a9322d04bf43c1c159df3079fb1790c5c154 /internal/processing/filters/v2
parent[chore] update go dependencies (#4304) (diff)
downloadgotosocial-4f2aa792b33fdd5fb4b22dec813b3668d7190522.tar.xz
[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 <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/processing/filters/v2')
-rw-r--r--internal/processing/filters/v2/create.go8
-rw-r--r--internal/processing/filters/v2/delete.go4
-rw-r--r--internal/processing/filters/v2/filters.go5
-rw-r--r--internal/processing/filters/v2/keywordcreate.go4
-rw-r--r--internal/processing/filters/v2/keyworddelete.go4
-rw-r--r--internal/processing/filters/v2/keywordupdate.go4
-rw-r--r--internal/processing/filters/v2/statuscreate.go4
-rw-r--r--internal/processing/filters/v2/statusdelete.go4
-rw-r--r--internal/processing/filters/v2/update.go4
9 files changed, 19 insertions, 22 deletions
diff --git a/internal/processing/filters/v2/create.go b/internal/processing/filters/v2/create.go
index d77c23424..154d80ee1 100644
--- a/internal/processing/filters/v2/create.go
+++ b/internal/processing/filters/v2/create.go
@@ -34,13 +34,13 @@ import (
// Create a new filter for the given account, using the provided parameters.
// These params should have already been validated by the time they reach this function.
-func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form *apimodel.FilterCreateRequestV2) (*apimodel.FilterV2, gtserror.WithCode) {
+func (p *Processor) Create(ctx context.Context, requester *gtsmodel.Account, form *apimodel.FilterCreateRequestV2) (*apimodel.FilterV2, gtserror.WithCode) {
var errWithCode gtserror.WithCode
// Create new filter model.
filter := &gtsmodel.Filter{
ID: id.NewULID(),
- AccountID: account.ID,
+ AccountID: requester.ID,
Title: form.Title,
}
@@ -104,8 +104,8 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
return nil, gtserror.NewErrorInternalError(err)
}
- // Send a filters changed event.
- p.stream.FiltersChanged(ctx, account)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
// Return as converted frontend filter model.
return typeutils.FilterToAPIFilterV2(filter), nil
diff --git a/internal/processing/filters/v2/delete.go b/internal/processing/filters/v2/delete.go
index ca3ade431..fdd6cca92 100644
--- a/internal/processing/filters/v2/delete.go
+++ b/internal/processing/filters/v2/delete.go
@@ -44,8 +44,8 @@ func (p *Processor) Delete(
return gtserror.NewErrorInternalError(err)
}
- // Stream a filters changed event to WS.
- p.stream.FiltersChanged(ctx, requester)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
return nil
}
diff --git a/internal/processing/filters/v2/filters.go b/internal/processing/filters/v2/filters.go
index 8c0ade1ca..08725ccde 100644
--- a/internal/processing/filters/v2/filters.go
+++ b/internal/processing/filters/v2/filters.go
@@ -19,7 +19,6 @@ package v2
import (
"code.superseriousbusiness.org/gotosocial/internal/processing/filters/common"
- "code.superseriousbusiness.org/gotosocial/internal/processing/stream"
"code.superseriousbusiness.org/gotosocial/internal/state"
"code.superseriousbusiness.org/gotosocial/internal/typeutils"
)
@@ -30,15 +29,13 @@ type Processor struct {
state *state.State
converter *typeutils.Converter
- stream *stream.Processor
}
-func New(state *state.State, converter *typeutils.Converter, common *common.Processor, stream *stream.Processor) Processor {
+func New(state *state.State, converter *typeutils.Converter, common *common.Processor) Processor {
return Processor{
c: common,
state: state,
converter: converter,
- stream: stream,
}
}
diff --git a/internal/processing/filters/v2/keywordcreate.go b/internal/processing/filters/v2/keywordcreate.go
index da91d5fd3..7ad7c3bd9 100644
--- a/internal/processing/filters/v2/keywordcreate.go
+++ b/internal/processing/filters/v2/keywordcreate.go
@@ -72,8 +72,8 @@ func (p *Processor) KeywordCreate(ctx context.Context, requester *gtsmodel.Accou
return nil, gtserror.NewErrorInternalError(err)
}
- // Stream a filters changed event to WS.
- p.stream.FiltersChanged(ctx, requester)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
return typeutils.FilterKeywordToAPIFilterKeyword(filterKeyword), nil
}
diff --git a/internal/processing/filters/v2/keyworddelete.go b/internal/processing/filters/v2/keyworddelete.go
index a0ec887e3..5393ffd53 100644
--- a/internal/processing/filters/v2/keyworddelete.go
+++ b/internal/processing/filters/v2/keyworddelete.go
@@ -54,8 +54,8 @@ func (p *Processor) KeywordDelete(
return gtserror.NewErrorInternalError(err)
}
- // Stream a filters changed event to WS.
- p.stream.FiltersChanged(ctx, requester)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
return nil
}
diff --git a/internal/processing/filters/v2/keywordupdate.go b/internal/processing/filters/v2/keywordupdate.go
index 9d1e5bd0c..047b079db 100644
--- a/internal/processing/filters/v2/keywordupdate.go
+++ b/internal/processing/filters/v2/keywordupdate.go
@@ -63,8 +63,8 @@ func (p *Processor) KeywordUpdate(
return nil, gtserror.NewErrorInternalError(err)
}
- // Stream a filters changed event to WS.
- p.stream.FiltersChanged(ctx, requester)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
return typeutils.FilterKeywordToAPIFilterKeyword(filterKeyword), nil
}
diff --git a/internal/processing/filters/v2/statuscreate.go b/internal/processing/filters/v2/statuscreate.go
index 1acab448c..2a3c3d74b 100644
--- a/internal/processing/filters/v2/statuscreate.go
+++ b/internal/processing/filters/v2/statuscreate.go
@@ -71,8 +71,8 @@ func (p *Processor) StatusCreate(ctx context.Context, requester *gtsmodel.Accoun
return nil, gtserror.NewErrorInternalError(err)
}
- // Stream a filters changed event to WS.
- p.stream.FiltersChanged(ctx, requester)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
return typeutils.FilterStatusToAPIFilterStatus(filterStatus), nil
}
diff --git a/internal/processing/filters/v2/statusdelete.go b/internal/processing/filters/v2/statusdelete.go
index 4309bac1a..321dc88e9 100644
--- a/internal/processing/filters/v2/statusdelete.go
+++ b/internal/processing/filters/v2/statusdelete.go
@@ -54,8 +54,8 @@ func (p *Processor) StatusDelete(
return gtserror.NewErrorInternalError(err)
}
- // Stream a filters changed event to WS.
- p.stream.FiltersChanged(ctx, requester)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
return nil
}
diff --git a/internal/processing/filters/v2/update.go b/internal/processing/filters/v2/update.go
index 96a43612f..f55f99bd5 100644
--- a/internal/processing/filters/v2/update.go
+++ b/internal/processing/filters/v2/update.go
@@ -135,8 +135,8 @@ func (p *Processor) Update(
return nil, gtserror.NewErrorInternalError(err)
}
- // Stream a filters changed event to WS.
- p.stream.FiltersChanged(ctx, requester)
+ // Handle filter change side-effects.
+ p.c.OnFilterChanged(ctx, requester)
// Return as converted frontend filter model.
return typeutils.FilterToAPIFilterV2(filter), nil