summaryrefslogtreecommitdiff
path: root/internal/gtsmodel/filter.go
diff options
context:
space:
mode:
authorLibravatar Vyr Cossont <VyrCossont@users.noreply.github.com>2024-06-06 11:16:20 -0700
committerLibravatar GitHub <noreply@github.com>2024-06-06 20:16:20 +0200
commite605788b4bd624d68c6a499b943f186c9ac3ebe3 (patch)
treedf25b2f67f5620ef4cd4a18195629c1b8b1bc4ad /internal/gtsmodel/filter.go
parent[feature] User muting (#2960) (diff)
downloadgotosocial-e605788b4bd624d68c6a499b943f186c9ac3ebe3.tar.xz
[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
Diffstat (limited to 'internal/gtsmodel/filter.go')
-rw-r--r--internal/gtsmodel/filter.go6
1 files changed, 6 insertions, 0 deletions
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