diff --git a/docs/api/swagger.yaml b/docs/api/swagger.yaml index c2e5c5fc3..d10aa5daa 100644 --- a/docs/api/swagger.yaml +++ b/docs/api/swagger.yaml @@ -3648,6 +3648,41 @@ paths: summary: Block account with id. tags: - accounts + /api/v1/accounts/{id}/featured_tags: + get: + description: 'THIS ENDPOINT IS CURRENTLY NOT FULLY IMPLEMENTED: it will always return an empty array.' + operationId: accountsFeaturedTags + parameters: + - description: The id of the account. + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: "" + schema: + items: + type: object + 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:accounts + summary: Get an array of target account's featured tags. + tags: + - accounts /api/v1/accounts/{id}/follow: post: consumes: diff --git a/internal/api/client/accounts/accounts.go b/internal/api/client/accounts/accounts.go index 0dbc5ea53..f21d23185 100644 --- a/internal/api/client/accounts/accounts.go +++ b/internal/api/client/accounts/accounts.go @@ -40,6 +40,7 @@ const ( BlockPath = BasePathWithID + "/block" DeletePath = BasePath + "/delete" + FeaturedTagsPath = BasePathWithID + "/featured_tags" FollowersPath = BasePathWithID + "/followers" FollowingPath = BasePathWithID + "/following" FollowPath = BasePathWithID + "/follow" @@ -98,6 +99,9 @@ func (m *Module) Route(attachHandler func(method string, path string, f ...gin.H // get account's statuses attachHandler(http.MethodGet, StatusesPath, m.AccountStatusesGETHandler) + // get account's featured tags + attachHandler(http.MethodGet, FeaturedTagsPath, m.AccountFeaturedTagsGETHandler) + // get following or followers attachHandler(http.MethodGet, FollowersPath, m.AccountFollowersGETHandler) attachHandler(http.MethodGet, FollowingPath, m.AccountFollowingGETHandler) diff --git a/internal/api/client/accounts/featuredtags.go b/internal/api/client/accounts/featuredtags.go new file mode 100644 index 000000000..312a92bcc --- /dev/null +++ b/internal/api/client/accounts/featuredtags.go @@ -0,0 +1,83 @@ +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package accounts + +import ( + "net/http" + + "github.com/gin-gonic/gin" + apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" + "github.com/superseriousbusiness/gotosocial/internal/gtserror" + "github.com/superseriousbusiness/gotosocial/internal/oauth" +) + +// AccountFeaturedTagsGETHandler swagger:operation GET /api/v1/accounts/{id}/featured_tags accountsFeaturedTags +// +// Get an array of target account's featured tags. +// +// THIS ENDPOINT IS CURRENTLY NOT FULLY IMPLEMENTED: it will always return an empty array. +// +// --- +// tags: +// - accounts +// +// produces: +// - application/json +// +// parameters: +// - +// name: id +// type: string +// description: The id of the account. +// in: path +// required: true +// +// security: +// - OAuth2 Bearer: +// - read:accounts +// +// responses: +// '200': +// schema: +// type: array +// items: +// type: object +// '400': +// description: bad request +// '401': +// description: unauthorized +// '404': +// description: not found +// '406': +// description: not acceptable +// '500': +// description: internal server error +func (m *Module) AccountFeaturedTagsGETHandler(c *gin.Context) { + _, err := oauth.Authed(c, true, true, true, true) + if err != nil { + apiutil.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGetV1) + return + } + + if _, err := apiutil.NegotiateAccept(c, apiutil.JSONAcceptHeaders...); err != nil { + apiutil.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGetV1) + return + } + + apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray) +}