[bugfix] Filter fixes (#2971)

* Add Filter.Expired convenience method, consistent with mutes

* Add missing Swagger for filter keyword/status delete and for 403s on moved accounts
This commit is contained in:
Vyr Cossont
2024-06-06 11:16:20 -07:00
committed by GitHub
parent 5e2d4fdb19
commit e605788b4b
12 changed files with 165 additions and 2 deletions

View File

@@ -40,6 +40,12 @@ type Filter struct {
ContextAccount *bool `bun:",nullzero,notnull,default:false"` // Apply filter when viewing an account profile.
}
// Expired returns whether the filter has expired at a given time.
// Filters without an expiration timestamp never expire.
func (f *Filter) Expired(now time.Time) bool {
return !f.ExpiresAt.IsZero() && !f.ExpiresAt.After(now)
}
// FilterKeyword stores a single keyword to filter statuses against.
type FilterKeyword struct {
ID string `bun:"type:CHAR(26),pk,nullzero,notnull,unique"` // id of this item in the database