v2

package
v0.17.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BasePath is the base path for serving the filters API, minus the 'api' prefix
	BasePath = "/v2/filters"
	// BasePathWithID is the base path with the ID key in it, for operations on an existing filter.
	BasePathWithID = BasePath + "/:" + apiutil.IDKey
	// FilterKeywordsPathWithID is the path for operations on an existing filter's keywords.
	FilterKeywordsPathWithID = BasePathWithID + "/keywords"
	// FilterStatusesPathWithID is the path for operations on an existing filter's statuses.
	FilterStatusesPathWithID = BasePathWithID + "/statuses"

	// KeywordPath is the base path for operations on filter keywords that don't require a filter ID.
	KeywordPath = BasePath + "/keywords"
	// KeywordPathWithKeywordID is the path for operations on an existing filter keyword.
	KeywordPathWithKeywordID = KeywordPath + "/:" + apiutil.IDKey

	// StatusPath is the base path for operations on filter statuses that don't require a filter ID.
	StatusPath = BasePath + "/statuses"
	// StatusPathWithStatusID is the path for operations on an existing filter status.
	StatusPathWithStatusID = StatusPath + "/:" + apiutil.IDKey
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module implements APIs for client-side aka "v1" filtering.

func New

func New(processor *processing.Processor) *Module

func (*Module) FilterDELETEHandler

func (m *Module) FilterDELETEHandler(c *gin.Context)

FilterDELETEHandler swagger:operation DELETE /api/v2/filters/{id} filterV2Delete

Delete a single filter with the given ID.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter
	in: path
	required: true

security:
- OAuth2 Bearer:
	- write:filters

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

func (*Module) FilterGETHandler

func (m *Module) FilterGETHandler(c *gin.Context)

FilterGETHandler swagger:operation GET /api/v2/filters/{id} filterV2Get

Get a single filter with the given ID.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter
	in: path
	required: true

security:
- OAuth2 Bearer:
	- read:filters

responses:
	'200':
		name: filter
		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

func (*Module) FilterKeywordDELETEHandler

func (m *Module) FilterKeywordDELETEHandler(c *gin.Context)

FilterKeywordDELETEHandler swagger:operation DELETE /api/v2/filters/keywords/{id} filterKeywordDelete

Delete a single filter keyword with the given ID.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter keyword
	in: path
	required: true

security:
- OAuth2 Bearer:
	- write:filters

responses:
	'200':
		description: filter keyword deleted
	'400':
		description: bad request
	'401':
		description: unauthorized
	'404':
		description: not found
	'406':
		description: not acceptable
	'500':
		description: internal server error

func (*Module) FilterKeywordGETHandler

func (m *Module) FilterKeywordGETHandler(c *gin.Context)

FilterKeywordGETHandler swagger:operation GET /api/v2/filters/keywords/{id} filterKeywordGet

Get a single filter keyword with the given ID.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter keyword
	in: path
	required: true

security:
- OAuth2 Bearer:
	- read:filters

responses:
	'200':
		name: filterKeyword
		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

func (*Module) FilterKeywordPOSTHandler

func (m *Module) FilterKeywordPOSTHandler(c *gin.Context)

FilterKeywordPOSTHandler swagger:operation POST /api/v2/filters/{id}/keywords filterKeywordPost

Add a filter keyword to an existing filter.

---
tags:
- filters

consumes:
- application/json
- application/xml
- application/x-www-form-urlencoded

produces:
- application/json

parameters:
-
	name: id
	in: path
	type: string
	required: true
	description: ID of the filter to add the filtered status to.
-
	name: keyword
	in: formData
	required: true
	description: |-
		The text to be filtered

		Sample: fnord
	type: string
	minLength: 1
	maxLength: 40
-
	name: whole_word
	in: formData
	description: |-
		Should the filter consider word boundaries?

		Sample: true
	type: boolean
	default: false

security:
- OAuth2 Bearer:
	- write:filters

responses:
	'200':
		name: filterKeyword
		description: New filter keyword.
		schema:
			"$ref": "#/definitions/filterKeyword"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden to moved accounts
	'404':
		description: not found
	'406':
		description: not acceptable
	'409':
		description: conflict (duplicate keyword)
	'422':
		description: unprocessable content
	'500':
		description: internal server error

func (*Module) FilterKeywordPUTHandler

func (m *Module) FilterKeywordPUTHandler(c *gin.Context)

FilterKeywordPUTHandler swagger:operation PUT /api/v2/filters/keywords{id} filterKeywordPut

Update a single filter keyword with the given ID.

---
tags:
- filters

consumes:
- application/json
- application/xml
- application/x-www-form-urlencoded

produces:
- application/json

parameters:
-
	name: id
	in: path
	type: string
	required: true
	description: ID of the filter keyword to update.
-
	name: keyword
	in: formData
	required: true
	description: |-
		The text to be filtered

		Sample: fnord
	type: string
	minLength: 1
	maxLength: 40
-
	name: whole_word
	in: formData
	description: |-
		Should the filter consider word boundaries?

		Sample: true
	type: boolean

security:
- OAuth2 Bearer:
	- write:filters

responses:
	'200':
		name: filterKeyword
		description: Updated filter keyword.
		schema:
			"$ref": "#/definitions/filterKeyword"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden to moved accounts
	'404':
		description: not found
	'406':
		description: not acceptable
	'409':
		description: conflict (duplicate keyword)
	'422':
		description: unprocessable content
	'500':
		description: internal server error

func (*Module) FilterKeywordsGETHandler

func (m *Module) FilterKeywordsGETHandler(c *gin.Context)

FilterKeywordsGETHandler swagger:operation GET /api/v2/filters/{id}/keywords filterKeywordsGet

Get all filter keywords for a given filter.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter
	in: path
	required: true

security:
- OAuth2 Bearer:
	- read:filters

responses:
	'200':
		name: filterKeywords
		description: Requested filter keywords.
		schema:
			type: array
			items:
				"$ref": "#/definitions/filterKeyword"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'404':
		description: not found
	'406':
		description: not acceptable
	'500':
		description: internal server error

func (*Module) FilterPOSTHandler

func (m *Module) FilterPOSTHandler(c *gin.Context)

FilterPOSTHandler swagger:operation POST /api/v2/filters filterV2Post

Create a single filter.

---
tags:
- filters

consumes:
- application/json
- application/xml
- application/x-www-form-urlencoded

produces:
- application/json

parameters:
-
	name: title
	in: formData
	required: true
	description: |-
		The name of the filter.

		Sample: illuminati nonsense
	type: string
	minLength: 1
	maxLength: 200
-
	name: context[]
	in: formData
	required: true
	description: |-
		The contexts in which the filter should be applied.

		Sample: home, public
	enum:
		- home
		- notifications
		- public
		- thread
		- account
	type: array
	items:
		type:
			string
	collectionFormat: multi
	minItems: 1
	uniqueItems: true
-
	name: expires_in
	in: formData
	description: |-
		Number of seconds from now that the filter should expire. If omitted, filter never expires.

		Sample: 86400
	type: number
-
	name: filter_action
	in: formData
	description: |-
		The action to be taken when a status matches this filter.

		Sample: warn
	type: string
	enum:
		- warn
		- hide
	default: warn
-
	name: keywords_attributes[][keyword]
	in: formData
	type: array
	items:
		type: string
	description: Keywords to be added (if not using id param) or updated (if using id param).
	collectionFormat: multi
-
	name: keywords_attributes[][whole_word]
	in: formData
	type: array
	items:
		type: boolean
	description: Should each keyword consider word boundaries?
	collectionFormat: multi
-
	name: statuses_attributes[][status_id]
	in: formData
	type: array
	items:
		type: string
	description: Statuses to be added to the filter.
	collectionFormat: multi

security:
- OAuth2 Bearer:
	- write:filters

responses:
	'200':
		name: filter
		description: New filter.
		schema:
			"$ref": "#/definitions/filterV2"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden to moved accounts
	'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

func (*Module) FilterPUTHandler

func (m *Module) FilterPUTHandler(c *gin.Context)

FilterPUTHandler swagger:operation PUT /api/v2/filters/{id} filterV2Put

Update a single filter with the given ID. 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.

---
tags:
- filters

consumes:
- application/json
- application/xml
- application/x-www-form-urlencoded

produces:
- application/json

parameters:
-
	name: id
	in: path
	type: string
	required: true
	description: ID of the filter.
-
	name: title
	in: formData
	required: true
	description: |-
		The name of the filter.

		Sample: illuminati nonsense
	type: string
	minLength: 1
	maxLength: 200
-
	name: keywords_attributes[][keyword]
	in: formData
	type: array
	items:
		type: string
	description: Keywords to be added to the created filter.
	collectionFormat: multi
-
	name: keywords_attributes[][whole_word]
	in: formData
	type: array
	items:
		type: boolean
	description: Should each keyword consider word boundaries?
	collectionFormat: multi
-
	name: statuses_attributes[][status_id]
	in: formData
	type: array
	items:
		type: string
	description: Statuses to be added to the newly created filter.
	collectionFormat: multi
-
	name: context[]
	in: formData
	required: true
	description: |-
		The contexts in which the filter should be applied.

		Sample: home, public
	enum:
		- home
		- notifications
		- public
		- thread
		- account
	type: array
	items:
		type:
			string
	collectionFormat: multi
	minItems: 1
	uniqueItems: true
-
	name: expires_in
	in: formData
	description: |-
		Number of seconds from now that the filter should expire.

		Sample: 86400
	type: number
-
	name: filter_action
	in: formData
	description: |-
		The action to be taken when a status matches this filter.

		Sample: warn
	type: string
	enum:
		- warn
		- hide

security:
- OAuth2 Bearer:
	- write:filters

responses:
	'200':
		name: filter
		description: Updated filter.
		schema:
			"$ref": "#/definitions/filterV2"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden to moved accounts
	'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

func (*Module) FilterStatusDELETEHandler

func (m *Module) FilterStatusDELETEHandler(c *gin.Context)

FilterStatusDELETEHandler swagger:operation DELETE /api/v2/filters/statuses/{id} filterStatusDelete

Delete a single filter status with the given ID.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter status
	in: path
	required: true

security:
- OAuth2 Bearer:
	- write:filters

responses:
	'200':
		description: filter status deleted
	'400':
		description: bad request
	'401':
		description: unauthorized
	'404':
		description: not found
	'406':
		description: not acceptable
	'500':
		description: internal server error

func (*Module) FilterStatusGETHandler

func (m *Module) FilterStatusGETHandler(c *gin.Context)

FilterStatusGETHandler swagger:operation GET /api/v2/filters/statuses/{id} filterStatusGet

Get a single filter status with the given ID.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter status
	in: path
	required: true

security:
- OAuth2 Bearer:
	- read:filters

responses:
	'200':
		name: filterStatus
		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

func (*Module) FilterStatusPOSTHandler

func (m *Module) FilterStatusPOSTHandler(c *gin.Context)

FilterStatusPOSTHandler swagger:operation POST /api/v2/filters/{id}/statuses filterStatusPost

Add a filter status to an existing filter.

---
tags:
- filters

consumes:
- application/json
- application/xml
- application/x-www-form-urlencoded

produces:
- application/json

parameters:
-
	name: id
	in: path
	type: string
	required: true
	description: ID of the filter to add the filtered status to.
-
	name: status_id
	in: formData
	required: true
	description: |-
		The ID of the status to filter.

		Sample: 01HXA2NE0K8T1C70K90E74GYD0
	type: string

security:
- OAuth2 Bearer:
	- write:filters

responses:
	'200':
		name: filterStatus
		description: New filter status.
		schema:
			"$ref": "#/definitions/filterStatus"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'403':
		description: forbidden to moved accounts
	'404':
		description: not found
	'406':
		description: not acceptable
	'409':
		description: conflict (duplicate status)
	'422':
		description: unprocessable content
	'500':
		description: internal server error

func (*Module) FilterStatusesGETHandler

func (m *Module) FilterStatusesGETHandler(c *gin.Context)

FilterStatusesGETHandler swagger:operation GET /api/v2/filters/{id}/statuses filterStatusesGet

Get all filter statuses for a given filter.

---
tags:
- filters

produces:
- application/json

parameters:
-
	name: id
	type: string
	description: ID of the filter
	in: path
	required: true

security:
- OAuth2 Bearer:
	- read:filters

responses:
	'200':
		name: filterStatuses
		description: Requested filter statuses.
		schema:
			type: array
			items:
				"$ref": "#/definitions/filterStatus"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'404':
		description: not found
	'406':
		description: not acceptable
	'500':
		description: internal server error

func (*Module) FiltersGETHandler

func (m *Module) FiltersGETHandler(c *gin.Context)

FiltersGETHandler swagger:operation GET /api/v2/filters filtersV2Get

Get all filters for the authenticated account.

---
tags:
- filters

produces:
- application/json

security:
- OAuth2 Bearer:
	- read:filters

responses:
	'200':
		name: filters
		description: Requested filters.
		schema:
			type: array
			items:
				"$ref": "#/definitions/filterV2"
	'400':
		description: bad request
	'401':
		description: unauthorized
	'404':
		description: not found
	'406':
		description: not acceptable
	'500':
		description: internal server error

func (*Module) Route

func (m *Module) Route(attachHandler func(method string, path string, f ...gin.HandlerFunc) gin.IRoutes)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL