[feature] Implement filters_changed stream event (#2972)

This commit is contained in:
Vyr Cossont
2024-06-07 01:51:13 -07:00
committed by GitHub
parent e605788b4b
commit afcfa48a7d
31 changed files with 303 additions and 12 deletions

View File

@ -83,5 +83,13 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
return nil, gtserror.NewErrorInternalError(err)
}
return p.apiFilter(ctx, filterKeyword)
apiFilter, errWithCode := p.apiFilter(ctx, filterKeyword)
if errWithCode != nil {
return nil, errWithCode
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return apiFilter, nil
}

View File

@ -63,5 +63,8 @@ func (p *Processor) Delete(
}
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return nil
}

View File

@ -18,6 +18,7 @@
package v1
import (
"github.com/superseriousbusiness/gotosocial/internal/processing/stream"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
@ -25,11 +26,13 @@ import (
type Processor struct {
state *state.State
converter *typeutils.Converter
stream *stream.Processor
}
func New(state *state.State, converter *typeutils.Converter) Processor {
func New(state *state.State, converter *typeutils.Converter, stream *stream.Processor) Processor {
return Processor{
state: state,
converter: converter,
stream: stream,
}
}

View File

@ -163,5 +163,13 @@ func (p *Processor) Update(
return nil, gtserror.NewErrorInternalError(err)
}
return p.apiFilter(ctx, filterKeyword)
apiFilter, errWithCode := p.apiFilter(ctx, filterKeyword)
if errWithCode != nil {
return nil, errWithCode
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return apiFilter, nil
}

View File

@ -71,5 +71,13 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
return nil, gtserror.NewErrorInternalError(err)
}
return p.apiFilter(ctx, filter)
apiFilter, errWithCode := p.apiFilter(ctx, filter)
if errWithCode != nil {
return nil, errWithCode
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return apiFilter, nil
}

View File

@ -49,5 +49,8 @@ func (p *Processor) Delete(
return gtserror.NewErrorInternalError(err)
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return nil
}

View File

@ -18,6 +18,7 @@
package v2
import (
"github.com/superseriousbusiness/gotosocial/internal/processing/stream"
"github.com/superseriousbusiness/gotosocial/internal/state"
"github.com/superseriousbusiness/gotosocial/internal/typeutils"
)
@ -25,11 +26,13 @@ import (
type Processor struct {
state *state.State
converter *typeutils.Converter
stream *stream.Processor
}
func New(state *state.State, converter *typeutils.Converter) Processor {
func New(state *state.State, converter *typeutils.Converter, stream *stream.Processor) Processor {
return Processor{
state: state,
converter: converter,
stream: stream,
}
}

View File

@ -63,5 +63,8 @@ func (p *Processor) KeywordCreate(ctx context.Context, account *gtsmodel.Account
return nil, gtserror.NewErrorInternalError(err)
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return p.converter.FilterKeywordToAPIFilterKeyword(ctx, filterKeyword), nil
}

View File

@ -49,5 +49,8 @@ func (p *Processor) KeywordDelete(
return gtserror.NewErrorInternalError(err)
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return nil
}

View File

@ -62,5 +62,8 @@ func (p *Processor) KeywordUpdate(
return nil, gtserror.NewErrorInternalError(err)
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return p.converter.FilterKeywordToAPIFilterKeyword(ctx, filterKeyword), nil
}

View File

@ -62,5 +62,8 @@ func (p *Processor) StatusCreate(ctx context.Context, account *gtsmodel.Account,
return nil, gtserror.NewErrorInternalError(err)
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return p.converter.FilterStatusToAPIFilterStatus(ctx, filterStatus), nil
}

View File

@ -49,5 +49,8 @@ func (p *Processor) StatusDelete(
return gtserror.NewErrorInternalError(err)
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return nil
}

View File

@ -121,5 +121,13 @@ func (p *Processor) Update(
filter.Keywords = filterKeywords
filter.Statuses = filterStatuses
return p.apiFilter(ctx, filter)
apiFilter, errWithCode := p.apiFilter(ctx, filter)
if errWithCode != nil {
return nil, errWithCode
}
// Send a filters changed event.
p.stream.FiltersChanged(ctx, account)
return apiFilter, nil
}