summaryrefslogtreecommitdiff
path: root/internal/api/model
diff options
context:
space:
mode:
authorLibravatar Vyr Cossont <VyrCossont@users.noreply.github.com>2024-05-31 03:55:56 -0700
committerLibravatar GitHub <noreply@github.com>2024-05-31 12:55:56 +0200
commit61a8d362557c1787d534024ed2f14e999b785cc3 (patch)
treef0ace4432170c0c88afa3233c2c327c808b7b92d /internal/api/model
parent[chore] little startup tweaks (#2941) (diff)
downloadgotosocial-61a8d362557c1787d534024ed2f14e999b785cc3.tar.xz
[feature] Implement Filter API v2 (#2936)
* Use correct entity name * We support server-side filters now * Document filter v1 methods that can throw a 409 * Validate v1 filter phrase as filter title * Always check v1 filter API status codes in tests * Document keyword minimum requirement on filter API v1 * Make it possible to specify filter keyword update columns per filter keyword * Implement v2 filter API * Fix lint and tests * Update Swagger spec * Fix filter update test * Update Swagger spec *correctly* * Update actual files Swagger spec was generated from * Remove keywords_attributes and statuses_attributes * Add test for serialization of empty filter * More helpful messages when object is owned by wrong account
Diffstat (limited to 'internal/api/model')
-rw-r--r--internal/api/model/filterv2.go87
1 files changed, 86 insertions, 1 deletions
diff --git a/internal/api/model/filterv2.go b/internal/api/model/filterv2.go
index 797c97213..51dabacb2 100644
--- a/internal/api/model/filterv2.go
+++ b/internal/api/model/filterv2.go
@@ -85,7 +85,7 @@ type FilterKeyword struct {
//
// Example: fnord
Keyword string `json:"keyword"`
- // Should the filter consider word boundaries?
+ // Should the filter keyword consider word boundaries?
//
// Example: true
WholeWord bool `json:"whole_word"`
@@ -104,3 +104,88 @@ type FilterStatus struct {
// The status ID to be filtered.
StatusID string `json:"phrase"`
}
+
+// FilterCreateRequestV2 captures params for creating a v2 filter.
+//
+// swagger:ignore
+type FilterCreateRequestV2 struct {
+ // The name of the filter.
+ //
+ // Required: true
+ // Example: fnord
+ Title string `form:"title" json:"title" xml:"title"`
+ // The contexts in which the filter should be applied.
+ //
+ // Required: true
+ // Minimum length: 1
+ // Unique: true
+ // Enum: home,notifications,public,thread,account
+ // Example: ["home", "public"]
+ Context []FilterContext `form:"context[]" json:"context" xml:"context"`
+ // The action to be taken when a status matches this filter. If omitted, defaults to warn.
+ // Enum:
+ // - warn
+ // - hide
+ // Example: warn
+ FilterAction *FilterAction `form:"filter_action" json:"filter_action" xml:"filter_action"`
+
+ // Number of seconds from now that the filter should expire. If omitted, filter never expires.
+ ExpiresIn *int `json:"-" form:"expires_in" xml:"expires_in"`
+ // Number of seconds from now that the filter should expire. If omitted, filter never expires.
+ //
+ // Example: 86400
+ ExpiresInI interface{} `json:"expires_in"`
+}
+
+// FilterKeywordCreateUpdateRequest captures params for creating or updating a filter keyword.
+//
+// swagger:ignore
+type FilterKeywordCreateUpdateRequest struct {
+ // The text to be filtered.
+ //
+ // Example: fnord
+ // Maximum length: 40
+ Keyword string `form:"keyword" json:"keyword" xml:"keyword"`
+ // Should the filter keyword consider word boundaries?
+ //
+ // Example: true
+ WholeWord *bool `form:"whole_word" json:"whole_word" xml:"whole_word"`
+}
+
+// FilterStatusCreateRequest captures params for creating a filter status.
+//
+// swagger:ignore
+type FilterStatusCreateRequest struct {
+ // The status ID to be filtered.
+ StatusID string `form:"status_id" json:"status_id" xml:"status_id"`
+}
+
+// FilterUpdateRequestV2 captures params for creating a v2 filter.
+//
+// swagger:ignore
+type FilterUpdateRequestV2 struct {
+ // The name of the filter.
+ //
+ // Example: illuminati nonsense
+ Title *string `form:"title" json:"title" xml:"title"`
+ // The contexts in which the filter should be applied.
+ //
+ // Minimum length: 1
+ // Unique: true
+ // Enum: home,notifications,public,thread,account
+ // Example: ["home", "public"]
+ Context *[]FilterContext `form:"context[]" json:"context" xml:"context"`
+ // The action to be taken when a status matches this filter.
+ // Enum:
+ // - warn
+ // - hide
+ // Example: warn
+ FilterAction *FilterAction `form:"filter_action" json:"filter_action" xml:"filter_action"`
+
+ // Number of seconds from now that the filter should expire. If omitted, filter never expires.
+ ExpiresIn *int `json:"-" form:"expires_in" xml:"expires_in"`
+ // Number of seconds from now that the filter should expire. If omitted, filter never expires.
+ //
+ // Example: 86400
+ ExpiresInI interface{} `json:"expires_in"`
+}