diff options
Diffstat (limited to 'internal/processing/filters')
| -rw-r--r-- | internal/processing/filters/common/common.go | 32 | ||||
| -rw-r--r-- | internal/processing/filters/v1/create.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v1/delete.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v1/filters.go | 5 | ||||
| -rw-r--r-- | internal/processing/filters/v1/update.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v2/create.go | 8 | ||||
| -rw-r--r-- | internal/processing/filters/v2/delete.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v2/filters.go | 5 | ||||
| -rw-r--r-- | internal/processing/filters/v2/keywordcreate.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v2/keyworddelete.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v2/keywordupdate.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v2/statuscreate.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v2/statusdelete.go | 4 | ||||
| -rw-r--r-- | internal/processing/filters/v2/update.go | 4 |
14 files changed, 56 insertions, 34 deletions
diff --git a/internal/processing/filters/common/common.go b/internal/processing/filters/common/common.go index a119d3bd4..8930b3aaf 100644 --- a/internal/processing/filters/common/common.go +++ b/internal/processing/filters/common/common.go @@ -28,12 +28,19 @@ import ( "code.superseriousbusiness.org/gotosocial/internal/gtscontext" "code.superseriousbusiness.org/gotosocial/internal/gtserror" "code.superseriousbusiness.org/gotosocial/internal/gtsmodel" + "code.superseriousbusiness.org/gotosocial/internal/log" + "code.superseriousbusiness.org/gotosocial/internal/processing/stream" "code.superseriousbusiness.org/gotosocial/internal/state" ) -type Processor struct{ state *state.State } +type Processor struct { + state *state.State + stream *stream.Processor +} -func New(state *state.State) *Processor { return &Processor{state} } +func New(state *state.State, stream *stream.Processor) *Processor { + return &Processor{state, stream} +} // CheckFilterExists calls .GetFilter() with a barebones context to not // fetch any sub-models, and not returning the result. this functionally @@ -160,6 +167,27 @@ func (p *Processor) GetFilterKeyword( return keyword, filter, nil } +// OnFilterChanged ... +func (p *Processor) OnFilterChanged(ctx context.Context, requester *gtsmodel.Account) { + + // Get list of list IDs created by this requesting account. + listIDs, err := p.state.DB.GetListIDsByAccountID(ctx, requester.ID) + if err != nil { + log.Errorf(ctx, "error getting account '%s' lists: %v", requester.Username, err) + } + + // Unprepare this requester's home timeline. + p.state.Caches.Timelines.Home.Unprepare(requester.ID) + + // Unprepare list timelines. + for _, id := range listIDs { + p.state.Caches.Timelines.List.Unprepare(id) + } + + // Send filter changed event for account. + p.stream.FiltersChanged(ctx, requester) +} + // FromAPIContexts converts a slice of frontend API model FilterContext types to our internal FilterContexts bit field. func FromAPIContexts(apiContexts []apimodel.FilterContext) (gtsmodel.FilterContexts, gtserror.WithCode) { var contexts gtsmodel.FilterContexts diff --git a/internal/processing/filters/v1/create.go b/internal/processing/filters/v1/create.go index b2ec69442..9f3fc17e0 100644 --- a/internal/processing/filters/v1/create.go +++ b/internal/processing/filters/v1/create.go @@ -91,8 +91,8 @@ func (p *Processor) Create(ctx context.Context, requester *gtsmodel.Account, for 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 keyword model. return typeutils.FilterKeywordToAPIFilterV1(filter, filterKeyword), nil diff --git a/internal/processing/filters/v1/delete.go b/internal/processing/filters/v1/delete.go index cab8b185d..65768140a 100644 --- a/internal/processing/filters/v1/delete.go +++ b/internal/processing/filters/v1/delete.go @@ -63,8 +63,8 @@ func (p *Processor) Delete( } } - // 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/v1/filters.go b/internal/processing/filters/v1/filters.go index bcbbd70c0..4492b4e76 100644 --- a/internal/processing/filters/v1/filters.go +++ b/internal/processing/filters/v1/filters.go @@ -19,7 +19,6 @@ package v1 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/v1/update.go b/internal/processing/filters/v1/update.go index 7e25e6fde..19699f328 100644 --- a/internal/processing/filters/v1/update.go +++ b/internal/processing/filters/v1/update.go @@ -166,8 +166,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 keyword model. return typeutils.FilterKeywordToAPIFilterV1(filter, filterKeyword), nil 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 := >smodel.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 |
