summaryrefslogtreecommitdiff
path: root/docs/api
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 /docs/api
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 'docs/api')
-rw-r--r--docs/api/swagger.yaml551
1 files changed, 549 insertions, 2 deletions
diff --git a/docs/api/swagger.yaml b/docs/api/swagger.yaml
index 7e61dcf1c..a83ea643a 100644
--- a/docs/api/swagger.yaml
+++ b/docs/api/swagger.yaml
@@ -1053,7 +1053,7 @@ definitions:
type: string
x-go-name: Keyword
whole_word:
- description: Should the filter consider word boundaries?
+ description: Should the filter keyword consider word boundaries?
example: true
type: boolean
x-go-name: WholeWord
@@ -5971,6 +5971,7 @@ paths:
Sample: fnord
in: formData
maxLength: 40
+ minLength: 1
name: phrase
required: true
type: string
@@ -6031,6 +6032,8 @@ paths:
description: not found
"406":
description: not acceptable
+ "409":
+ description: conflict (duplicate keyword)
"422":
description: unprocessable content
"500":
@@ -6045,7 +6048,7 @@ paths:
delete:
operationId: filterV1Delete
parameters:
- - description: ID of the list
+ - description: ID of the filter
in: path
name: id
required: true
@@ -6120,6 +6123,7 @@ paths:
Sample: fnord
in: formData
maxLength: 40
+ minLength: 1
name: phrase
required: true
type: string
@@ -6180,6 +6184,8 @@ paths:
description: not found
"406":
description: not acceptable
+ "409":
+ description: conflict (duplicate keyword)
"422":
description: unprocessable content
"500":
@@ -8759,6 +8765,547 @@ paths:
summary: View + page through known accounts according to given filters.
tags:
- admin
+ /api/v2/filters:
+ get:
+ operationId: filtersV2Get
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Requested filters.
+ schema:
+ items:
+ $ref: '#/definitions/filterV2'
+ type: array
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - read:filters
+ summary: Get all filters for the authenticated account.
+ tags:
+ - filters
+ post:
+ consumes:
+ - application/json
+ - application/xml
+ - application/x-www-form-urlencoded
+ operationId: filterV2Post
+ parameters:
+ - description: |-
+ The name of the filter.
+
+ Sample: illuminati nonsense
+ in: formData
+ maxLength: 200
+ minLength: 1
+ name: title
+ required: true
+ type: string
+ - collectionFormat: multi
+ description: |-
+ The contexts in which the filter should be applied.
+
+ Sample: home, public
+ enum:
+ - home
+ - notifications
+ - public
+ - thread
+ - account
+ in: formData
+ items:
+ type: string
+ minItems: 1
+ name: context[]
+ required: true
+ type: array
+ uniqueItems: true
+ - description: |-
+ Number of seconds from now that the filter should expire. If omitted, filter never expires.
+
+ Sample: 86400
+ in: formData
+ name: expires_in
+ type: number
+ - default: warn
+ description: |-
+ The action to be taken when a status matches this filter.
+
+ Sample: warn
+ enum:
+ - warn
+ - hide
+ in: formData
+ name: filter_action
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: New filter.
+ schema:
+ $ref: '#/definitions/filterV2'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "409":
+ description: conflict (duplicate title, keyword, or status)
+ "422":
+ description: unprocessable content
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - write:filters
+ summary: Create a single filter.
+ tags:
+ - filters
+ /api/v2/filters/{id}:
+ delete:
+ operationId: filterV2Delete
+ parameters:
+ - description: ID of the filter
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: filter deleted
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - write:filters
+ summary: Delete a single filter with the given ID.
+ tags:
+ - filters
+ get:
+ operationId: filterV2Get
+ parameters:
+ - description: ID of the filter
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Requested filter.
+ schema:
+ $ref: '#/definitions/filterV2'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - read:filters
+ summary: Get a single filter with the given ID.
+ tags:
+ - filters
+ put:
+ consumes:
+ - application/json
+ - application/xml
+ - application/x-www-form-urlencoded
+ description: |-
+ Note that this is actually closer to a PATCH operation:
+ only provided fields will be updated, and omitted fields will remain set to previous values.
+ operationId: filterV2Put
+ parameters:
+ - description: ID of the filter.
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: |-
+ The name of the filter.
+
+ Sample: illuminati nonsense
+ in: formData
+ maxLength: 200
+ minLength: 1
+ name: title
+ required: true
+ type: string
+ - collectionFormat: multi
+ description: |-
+ The contexts in which the filter should be applied.
+
+ Sample: home, public
+ enum:
+ - home
+ - notifications
+ - public
+ - thread
+ - account
+ in: formData
+ items:
+ type: string
+ minItems: 1
+ name: context[]
+ required: true
+ type: array
+ uniqueItems: true
+ - description: |-
+ Number of seconds from now that the filter should expire.
+
+ Sample: 86400
+ in: formData
+ name: expires_in
+ type: number
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Updated filter.
+ schema:
+ $ref: '#/definitions/filterV2'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "409":
+ description: conflict (duplicate title, keyword, or status)
+ "422":
+ description: unprocessable content
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - write:filters
+ summary: Update a single filter with the given ID.
+ tags:
+ - filters
+ /api/v2/filters/{id}/keywords:
+ get:
+ operationId: filterKeywordsGet
+ parameters:
+ - description: ID of the filter
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Requested filter keywords.
+ schema:
+ items:
+ $ref: '#/definitions/filterKeyword'
+ type: array
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - read:filters
+ summary: Get all filter keywords for a given filter.
+ tags:
+ - filters
+ post:
+ consumes:
+ - application/json
+ - application/xml
+ - application/x-www-form-urlencoded
+ operationId: filterKeywordPost
+ parameters:
+ - description: ID of the filter to add the filtered status to.
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: |-
+ The text to be filtered
+
+ Sample: fnord
+ in: formData
+ maxLength: 40
+ minLength: 1
+ name: keyword
+ required: true
+ type: string
+ - default: false
+ description: |-
+ Should the filter consider word boundaries?
+
+ Sample: true
+ in: formData
+ name: whole_word
+ type: boolean
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: New filter keyword.
+ schema:
+ $ref: '#/definitions/filterKeyword'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "409":
+ description: conflict (duplicate keyword)
+ "422":
+ description: unprocessable content
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - write:filters
+ summary: Add a filter keyword to an existing filter.
+ tags:
+ - filters
+ /api/v2/filters/{id}/statuses:
+ get:
+ operationId: filterStatusesGet
+ parameters:
+ - description: ID of the filter
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Requested filter statuses.
+ schema:
+ items:
+ $ref: '#/definitions/filterStatus'
+ type: array
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - read:filters
+ summary: Get all filter statuses for a given filter.
+ tags:
+ - filters
+ post:
+ consumes:
+ - application/json
+ - application/xml
+ - application/x-www-form-urlencoded
+ operationId: filterStatusPost
+ parameters:
+ - description: ID of the filter to add the filtered status to.
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: |-
+ The ID of the status to filter.
+
+ Sample: 01HXA2NE0K8T1C70K90E74GYD0
+ in: formData
+ name: status_id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: New filter status.
+ schema:
+ $ref: '#/definitions/filterStatus'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "409":
+ description: conflict (duplicate status)
+ "422":
+ description: unprocessable content
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - write:filters
+ summary: Add a filter status to an existing filter.
+ tags:
+ - filters
+ /api/v2/filters/keywords/{id}:
+ get:
+ operationId: filterKeywordGet
+ parameters:
+ - description: ID of the filter keyword
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Requested filter keyword.
+ schema:
+ $ref: '#/definitions/filterKeyword'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - read:filters
+ summary: Get a single filter keyword with the given ID.
+ tags:
+ - filters
+ /api/v2/filters/keywords{id}:
+ put:
+ consumes:
+ - application/json
+ - application/xml
+ - application/x-www-form-urlencoded
+ operationId: filterKeywordPut
+ parameters:
+ - description: ID of the filter keyword to update.
+ in: path
+ name: id
+ required: true
+ type: string
+ - description: |-
+ The text to be filtered
+
+ Sample: fnord
+ in: formData
+ maxLength: 40
+ minLength: 1
+ name: keyword
+ required: true
+ type: string
+ - description: |-
+ Should the filter consider word boundaries?
+
+ Sample: true
+ in: formData
+ name: whole_word
+ type: boolean
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Updated filter keyword.
+ schema:
+ $ref: '#/definitions/filterKeyword'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "409":
+ description: conflict (duplicate keyword)
+ "422":
+ description: unprocessable content
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - write:filters
+ summary: Update a single filter keyword with the given ID.
+ tags:
+ - filters
+ /api/v2/filters/statuses/{id}:
+ get:
+ operationId: filterStatusGet
+ parameters:
+ - description: ID of the filter status
+ in: path
+ name: id
+ required: true
+ type: string
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: Requested filter status.
+ schema:
+ $ref: '#/definitions/filterStatus'
+ "400":
+ description: bad request
+ "401":
+ description: unauthorized
+ "404":
+ description: not found
+ "406":
+ description: not acceptable
+ "500":
+ description: internal server error
+ security:
+ - OAuth2 Bearer:
+ - read:filters
+ summary: Get a single filter status with the given ID.
+ tags:
+ - filters
/api/v2/instance:
get:
operationId: instanceGetV2