mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-24 05:43:32 -06:00
[feature] Hashtag federation (in/out), hashtag client API endpoints (#2032)
* update go-fed * do the things * remove unused columns from tags * update to latest lingo from main * further tag shenanigans * serve stub page at tag endpoint * we did it lads * tests, oh tests, ohhh tests, oh tests (doo doo doo doo) * swagger docs * document hashtag usage + federation * instanceGet * don't bother parsing tag href * rename whereStartsWith -> whereStartsLike * remove GetOrCreateTag * dont cache status tag timelineability
This commit is contained in:
parent
ed2477ebea
commit
2796a2e82f
69 changed files with 2536 additions and 482 deletions
|
|
@ -27,7 +27,7 @@ import (
|
|||
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
||||
)
|
||||
|
||||
// SearchGETHandler swagger:operation GET /api/v1/search searchGet
|
||||
// SearchGETHandler swagger:operation GET /api/{api_version}/search searchGet
|
||||
//
|
||||
// Search for statuses, accounts, or hashtags, on this instance or elsewhere.
|
||||
//
|
||||
|
|
@ -42,6 +42,15 @@ import (
|
|||
//
|
||||
// parameters:
|
||||
// -
|
||||
// name: api_version
|
||||
// type: string
|
||||
// in: path
|
||||
// description: >-
|
||||
// Version of the API to use. Must be either `v1` or `v2`.
|
||||
// If v1 is used, Hashtag results will be a slice of strings.
|
||||
// If v2 is used, Hashtag results will be a slice of apimodel tags.
|
||||
// required: true
|
||||
// -
|
||||
// name: max_id
|
||||
// type: string
|
||||
// description: >-
|
||||
|
|
@ -88,6 +97,7 @@ import (
|
|||
// - `@[username]` -- search for an account with the given username on any domain. Can return multiple results.
|
||||
// - @[username]@[domain]` -- search for a remote account with exact username and domain. Will only ever return 1 result at most.
|
||||
// - `https://example.org/some/arbitrary/url` -- search for an account OR a status with the given URL. Will only ever return 1 result at most.
|
||||
// - `#[hashtag_name]` -- search for a hashtag with the given hashtag name, or starting with the given hashtag name. Case insensitive. Can return multiple results.
|
||||
// - any arbitrary string -- search for accounts or statuses containing the given string. Can return multiple results.
|
||||
// in: query
|
||||
// required: true
|
||||
|
|
@ -97,9 +107,9 @@ import (
|
|||
// description: |-
|
||||
// Type of item to return. One of:
|
||||
// - `` -- empty string; return any/all results.
|
||||
// - `accounts` -- return account(s).
|
||||
// - `statuses` -- return status(es).
|
||||
// - `hashtags` -- return hashtag(s).
|
||||
// - `accounts` -- return only account(s).
|
||||
// - `statuses` -- return only status(es).
|
||||
// - `hashtags` -- return only hashtag(s).
|
||||
// If `type` is specified, paging can be performed using max_id and min_id parameters.
|
||||
// If `type` is not specified, see the `offset` parameter for paging.
|
||||
// in: query
|
||||
|
|
@ -138,9 +148,7 @@ import (
|
|||
// name: search results
|
||||
// description: Results of the search.
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// "$ref": "#/definitions/searchResult"
|
||||
// "$ref": "#/definitions/searchResult"
|
||||
// '400':
|
||||
// description: bad request
|
||||
// '401':
|
||||
|
|
@ -152,6 +160,15 @@ import (
|
|||
// '500':
|
||||
// description: internal server error
|
||||
func (m *Module) SearchGETHandler(c *gin.Context) {
|
||||
apiVersion, errWithCode := apiutil.ParseAPIVersion(
|
||||
c.Param(apiutil.APIVersionKey),
|
||||
[]string{apiutil.APIv1, apiutil.APIv2}...,
|
||||
)
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
}
|
||||
|
||||
authed, err := oauth.Authed(c, true, true, true, true)
|
||||
if err != nil {
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGetV1)
|
||||
|
|
@ -209,6 +226,7 @@ func (m *Module) SearchGETHandler(c *gin.Context) {
|
|||
Resolve: resolve,
|
||||
Following: following,
|
||||
ExcludeUnreviewed: excludeUnreviewed,
|
||||
APIv1: apiVersion == apiutil.APIv1,
|
||||
}
|
||||
|
||||
results, errWithCode := m.processor.Search().Get(c.Request.Context(), authed.Account, searchRequest)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue