From e605788b4bd624d68c6a499b943f186c9ac3ebe3 Mon Sep 17 00:00:00 2001 From: Vyr Cossont Date: Thu, 6 Jun 2024 11:16:20 -0700 Subject: [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 --- internal/gtsmodel/filter.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'internal/gtsmodel') diff --git a/internal/gtsmodel/filter.go b/internal/gtsmodel/filter.go index b1e8f5cac..e670e6fc0 100644 --- a/internal/gtsmodel/filter.go +++ b/internal/gtsmodel/filter.go @@ -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 -- cgit v1.2.3