2021-05-31 15:36:35 +00:00
|
|
|
package emoji
|
|
|
|
|
2021-06-13 16:42:28 +00:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2021-12-11 16:50:00 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/api"
|
2022-06-08 18:38:03 +00:00
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
|
|
|
"github.com/superseriousbusiness/gotosocial/internal/oauth"
|
2021-06-13 16:42:28 +00:00
|
|
|
)
|
2021-05-31 15:36:35 +00:00
|
|
|
|
2022-09-13 11:30:07 +00:00
|
|
|
// EmojisGETHandler swagger:operation GET /api/v1/custom_emojis customEmojisGet
|
|
|
|
//
|
|
|
|
// Get an array of custom emojis available on the instance.
|
|
|
|
//
|
2022-09-28 17:30:40 +00:00
|
|
|
// ---
|
|
|
|
// tags:
|
|
|
|
// - custom_emojis
|
2022-09-13 11:30:07 +00:00
|
|
|
//
|
2022-09-28 17:30:40 +00:00
|
|
|
// produces:
|
|
|
|
// - application/json
|
2022-09-13 11:30:07 +00:00
|
|
|
//
|
2022-09-28 17:30:40 +00:00
|
|
|
// security:
|
|
|
|
// - OAuth2 Bearer:
|
|
|
|
// - read:custom_emojis
|
2022-09-13 11:30:07 +00:00
|
|
|
//
|
2022-09-28 17:30:40 +00:00
|
|
|
// responses:
|
|
|
|
// '200':
|
|
|
|
// description: Array of custom emojis.
|
|
|
|
// schema:
|
|
|
|
// type: array
|
|
|
|
// items:
|
|
|
|
// "$ref": "#/definitions/emoji"
|
|
|
|
// '401':
|
|
|
|
// description: unauthorized
|
|
|
|
// '406':
|
|
|
|
// description: not acceptable
|
|
|
|
// '500':
|
|
|
|
// description: internal server error
|
2021-05-31 15:36:35 +00:00
|
|
|
func (m *Module) EmojisGETHandler(c *gin.Context) {
|
2022-06-08 18:38:03 +00:00
|
|
|
if _, err := oauth.Authed(c, true, true, true, true); err != nil {
|
|
|
|
api.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGet)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-12-11 16:50:00 +00:00
|
|
|
if _, err := api.NegotiateAccept(c, api.JSONAcceptHeaders...); err != nil {
|
2022-06-08 18:38:03 +00:00
|
|
|
api.ErrorHandler(c, gtserror.NewErrorNotAcceptable(err, err.Error()), m.processor.InstanceGet)
|
2021-12-11 16:50:00 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-20 08:34:36 +00:00
|
|
|
emojis, errWithCode := m.processor.CustomEmojisGet(c)
|
|
|
|
if errWithCode != nil {
|
2022-06-08 18:38:03 +00:00
|
|
|
api.ErrorHandler(c, errWithCode, m.processor.InstanceGet)
|
2022-05-20 08:34:36 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, emojis)
|
2021-05-31 15:36:35 +00:00
|
|
|
}
|