summaryrefslogtreecommitdiff
path: root/internal/processing/filters/common
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing/filters/common')
-rw-r--r--internal/processing/filters/common/common.go32
1 files changed, 30 insertions, 2 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