mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 18:22:11 +00:00
Compile filter keyword regexps when touched through PutFilter or UpdateFilter (#2951)
Followup to #2903
This commit is contained in:
parent
f17dd62ff5
commit
45fe295caa
|
@ -154,6 +154,13 @@ func (f *filterDB) populateFilter(ctx context.Context, filter *gtsmodel.Filter)
|
|||
}
|
||||
|
||||
func (f *filterDB) PutFilter(ctx context.Context, filter *gtsmodel.Filter) error {
|
||||
// Pre-compile filter keyword regular expressions.
|
||||
for _, filterKeyword := range filter.Keywords {
|
||||
if err := filterKeyword.Compile(); err != nil {
|
||||
return gtserror.Newf("error compiling filter keyword regex: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Update database.
|
||||
if err := f.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
|
||||
if _, err := tx.
|
||||
|
@ -225,6 +232,13 @@ func (f *filterDB) UpdateFilter(
|
|||
}
|
||||
}
|
||||
|
||||
// Pre-compile filter keyword regular expressions.
|
||||
for _, filterKeyword := range filter.Keywords {
|
||||
if err := filterKeyword.Compile(); err != nil {
|
||||
return gtserror.Newf("error compiling filter keyword regex: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Update database.
|
||||
if err := f.db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error {
|
||||
if _, err := tx.
|
||||
|
|
Loading…
Reference in a new issue