mirror of
https://codeberg.org/superseriousbusiness/gotosocial.git
synced 2024-12-18 07:01:49 +03:00
Compile filter keyword regexps when touched through PutFilter or UpdateFilter (#2951)
Followup to #2903
This commit is contained in:
parent
f17dd62ff5
commit
45fe295caa
1 changed files with 14 additions and 0 deletions
|
@ -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