diff options
Diffstat (limited to 'internal/api/client/mutes/mutesget.go')
-rw-r--r-- | internal/api/client/mutes/mutesget.go | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/internal/api/client/mutes/mutesget.go b/internal/api/client/mutes/mutesget.go index d609da868..7fcbc2b44 100644 --- a/internal/api/client/mutes/mutesget.go +++ b/internal/api/client/mutes/mutesget.go @@ -24,14 +24,13 @@ import ( apiutil "github.com/superseriousbusiness/gotosocial/internal/api/util" "github.com/superseriousbusiness/gotosocial/internal/gtserror" "github.com/superseriousbusiness/gotosocial/internal/oauth" + "github.com/superseriousbusiness/gotosocial/internal/paging" ) // MutesGETHandler swagger:operation GET /api/v1/mutes mutesGet // // Get an array of accounts that requesting account has muted. // -// NOT IMPLEMENTED YET: Will currently always return an array of length 0. -// // The next and previous queries can be parsed from the returned Link header. // Example: // @@ -89,6 +88,7 @@ import ( // // responses: // '200': +// description: List of muted accounts, including when their mutes expire (if applicable). // headers: // Link: // type: string @@ -96,7 +96,7 @@ import ( // schema: // type: array // items: -// "$ref": "#/definitions/account" +// "$ref": "#/definitions/mutedAccount" // '400': // description: bad request // '401': @@ -108,7 +108,8 @@ import ( // '500': // description: internal server error func (m *Module) MutesGETHandler(c *gin.Context) { - if _, err := oauth.Authed(c, true, true, true, true); err != nil { + authed, err := oauth.Authed(c, true, true, true, true) + if err != nil { apiutil.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGetV1) return } @@ -118,5 +119,29 @@ func (m *Module) MutesGETHandler(c *gin.Context) { return } - apiutil.Data(c, http.StatusOK, apiutil.AppJSON, apiutil.EmptyJSONArray) + page, errWithCode := paging.ParseIDPage(c, + 1, // min limit + 80, // max limit + 40, // default limit + ) + if errWithCode != nil { + apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) + return + } + + resp, errWithCode := m.processor.Account().MutesGet( + c.Request.Context(), + authed.Account, + page, + ) + if errWithCode != nil { + apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1) + return + } + + if resp.LinkHeader != "" { + c.Header("Link", resp.LinkHeader) + } + + apiutil.JSON(c, http.StatusOK, resp.Items) } |