summaryrefslogtreecommitdiff
path: root/internal/api/model
diff options
context:
space:
mode:
authorLibravatar Vyr Cossont <VyrCossont@users.noreply.github.com>2024-06-14 01:11:41 -0700
committerLibravatar GitHub <noreply@github.com>2024-06-14 10:11:41 +0200
commitb789fe2bc72a1b1bca50da498ae22c10a4e7acc2 (patch)
treed43f049b4ee30bfbab2d1c1a10c02af904df9fbb /internal/api/model
parent[docs] Rework README a bit, import into docs (#3006) (diff)
downloadgotosocial-b789fe2bc72a1b1bca50da498ae22c10a4e7acc2.tar.xz
[feature] filter API v2: Restore keywords_attributes and statuses_attributes (#2995)
These filter API v2 features were cut late in development because the form encoding version is hard to implement correctly and because I thought no clients actually used `keywords_attributes`. Unfortunately, Phanpy does use `keywords_attributes`.
Diffstat (limited to 'internal/api/model')
-rw-r--r--internal/api/model/filterv2.go69
1 files changed, 67 insertions, 2 deletions
diff --git a/internal/api/model/filterv2.go b/internal/api/model/filterv2.go
index 51dabacb2..242c569dc 100644
--- a/internal/api/model/filterv2.go
+++ b/internal/api/model/filterv2.go
@@ -135,9 +135,21 @@ type FilterCreateRequestV2 struct {
//
// Example: 86400
ExpiresInI interface{} `json:"expires_in"`
+
+ // Keywords to be added to the newly created filter.
+ Keywords []FilterKeywordCreateUpdateRequest `form:"-" json:"keywords_attributes" xml:"keywords_attributes"`
+ // Form data version of Keywords[].Keyword.
+ KeywordsAttributesKeyword []string `form:"keywords_attributes[][keyword]" json:"-" xml:"-"`
+ // Form data version of Keywords[].WholeWord.
+ KeywordsAttributesWholeWord []bool `form:"keywords_attributes[][whole_word]" json:"-" xml:"-"`
+
+ // Statuses to be added to the newly created filter.
+ Statuses []FilterStatusCreateRequest `form:"-" json:"statuses_attributes" xml:"statuses_attributes"`
+ // Form data version of Statuses[].StatusID.
+ StatusesAttributesStatusID []string `form:"statuses_attributes[][status_id]" json:"-" xml:"-"`
}
-// FilterKeywordCreateUpdateRequest captures params for creating or updating a filter keyword.
+// FilterKeywordCreateUpdateRequest captures params for creating or updating a filter keyword while creating a v2 filter or as a standalone operation.
//
// swagger:ignore
type FilterKeywordCreateUpdateRequest struct {
@@ -152,7 +164,7 @@ type FilterKeywordCreateUpdateRequest struct {
WholeWord *bool `form:"whole_word" json:"whole_word" xml:"whole_word"`
}
-// FilterStatusCreateRequest captures params for creating a filter status.
+// FilterStatusCreateRequest captures params for a status while creating a v2 filter or filter status.
//
// swagger:ignore
type FilterStatusCreateRequest struct {
@@ -188,4 +200,57 @@ type FilterUpdateRequestV2 struct {
//
// Example: 86400
ExpiresInI interface{} `json:"expires_in"`
+
+ // Keywords to be added to the filter, modified, or removed.
+ Keywords []FilterKeywordCreateUpdateDeleteRequest `form:"-" json:"keywords_attributes" xml:"keywords_attributes"`
+ // Form data version of Keywords[].ID.
+ KeywordsAttributesID []string `form:"keywords_attributes[][id]" json:"-" xml:"-"`
+ // Form data version of Keywords[].Keyword.
+ KeywordsAttributesKeyword []string `form:"keywords_attributes[][keyword]" json:"-" xml:"-"`
+ // Form data version of Keywords[].WholeWord.
+ KeywordsAttributesWholeWord []bool `form:"keywords_attributes[][whole_word]" json:"-" xml:"-"`
+ // Form data version of Keywords[].Destroy.
+ KeywordsAttributesDestroy []bool `form:"keywords_attributes[][_destroy]" json:"-" xml:"-"`
+
+ // Statuses to be added to the filter, or removed.
+ Statuses []FilterStatusCreateDeleteRequest `form:"-" json:"statuses_attributes" xml:"statuses_attributes"`
+ // Form data version of Statuses[].ID.
+ StatusesAttributesID []string `form:"statuses_attributes[][id]" json:"-" xml:"-"`
+ // Form data version of Statuses[].ID.
+ StatusesAttributesStatusID []string `form:"statuses_attributes[][status_id]" json:"-" xml:"-"`
+ // Form data version of Statuses[].Destroy.
+ StatusesAttributesDestroy []bool `form:"statuses_attributes[][_destroy]" json:"-" xml:"-"`
+}
+
+// FilterKeywordCreateUpdateDeleteRequest captures params for creating, updating, or deleting a keyword while updating a v2 filter.
+//
+// swagger:ignore
+type FilterKeywordCreateUpdateDeleteRequest struct {
+ // The ID of the filter keyword entry in the database.
+ // Optional: use to modify or delete an existing keyword instead of adding a new one.
+ ID *string `json:"id" xml:"id"`
+ // The text to be filtered.
+ //
+ // Example: fnord
+ // Maximum length: 40
+ Keyword *string `json:"keyword" xml:"keyword"`
+ // Should the filter keyword consider word boundaries?
+ //
+ // Example: true
+ WholeWord *bool `json:"whole_word" xml:"whole_word"`
+ // Remove this filter keyword. Requires an ID.
+ Destroy *bool `json:"_destroy" xml:"_destroy"`
+}
+
+// FilterStatusCreateDeleteRequest captures params for creating or deleting a status while updating a v2 filter.
+//
+// swagger:ignore
+type FilterStatusCreateDeleteRequest struct {
+ // The ID of the filter status entry in the database.
+ // Optional: use to delete an existing status instead of adding a new one.
+ ID *string `json:"id" xml:"id"`
+ // The status ID to be filtered.
+ StatusID *string `json:"status_id" xml:"status_id"`
+ // Remove this filter status. Requires an ID.
+ Destroy *bool `json:"_destroy" xml:"_destroy"`
}