diff options
author | 2024-12-08 13:47:07 +0100 | |
---|---|---|
committer | 2024-12-08 13:47:07 +0100 | |
commit | 642f5230e68b08fdcb993a92e9fda119892d5ccf (patch) | |
tree | 7dfb21a27d38260060bb301bf7b64b91d253b927 /internal/api | |
parent | [feature] add support for receiving federated status edits (#3597) (diff) | |
download | gotosocial-642f5230e68b08fdcb993a92e9fda119892d5ccf.tar.xz |
[chore] stub /api/v1/accounts/{id}/featured_tags endpoint (#3598)
* [chore] stub /api/v1/accounts/{id}/featured_tags endpoint
* fix swagger parsing issue
---------
Co-authored-by: tobi <31960611+tsmethurst@users.noreply.github.com>
Co-authored-by: tobi <tobi.smethurst@protonmail.com>
Diffstat (limited to 'internal/api')
-rw-r--r-- | internal/api/client/accounts/accounts.go | 4 | ||||
-rw-r--r-- | internal/api/client/accounts/featuredtags.go | 83 |
2 files changed, 87 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>. + +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) +} |