mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-15 19:57:33 -06:00
start refactoring return codes from fedi endpoints, remove some cruft
This commit is contained in:
parent
c6044d0142
commit
47051a26d6
28 changed files with 346 additions and 291 deletions
|
|
@ -20,16 +20,12 @@ package emoji
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
apiutil "code.superseriousbusiness.org/gotosocial/internal/api/util"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/processing"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
const (
|
||||
// EmojiIDKey is for emoji IDs
|
||||
EmojiIDKey = "id"
|
||||
// EmojiBasePath is the base path for serving AP Emojis, minus the "emoji" prefix
|
||||
EmojiWithIDPath = "/:" + EmojiIDKey
|
||||
)
|
||||
const EmojiWithIDPath = "/:" + apiutil.IDKey
|
||||
|
||||
type Module struct {
|
||||
processor *processing.Processor
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import (
|
|||
)
|
||||
|
||||
func (m *Module) EmojiGetHandler(c *gin.Context) {
|
||||
requestedEmojiID := strings.ToUpper(c.Param(EmojiIDKey))
|
||||
if requestedEmojiID == "" {
|
||||
emojiID := strings.ToUpper(c.Param(apiutil.IDKey))
|
||||
if emojiID == "" {
|
||||
err := errors.New("no emoji id specified in request")
|
||||
apiutil.ErrorHandler(c, gtserror.NewErrorBadRequest(err, err.Error()), m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
@ -41,7 +41,7 @@ func (m *Module) EmojiGetHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
resp, errWithCode := m.processor.Fedi().EmojiGet(c.Request.Context(), requestedEmojiID)
|
||||
resp, errWithCode := m.processor.Fedi().EmojiGet(c.Request.Context(), emojiID)
|
||||
if errWithCode != nil {
|
||||
apiutil.ErrorHandler(c, errWithCode, m.processor.InstanceGetV1)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
|
||||
"code.superseriousbusiness.org/gotosocial/internal/admin"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/api/activitypub/emoji"
|
||||
apiutil "code.superseriousbusiness.org/gotosocial/internal/api/util"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/db"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/email"
|
||||
"code.superseriousbusiness.org/gotosocial/internal/federation"
|
||||
|
|
@ -122,7 +123,7 @@ func (suite *EmojiGetTestSuite) TestGetEmoji() {
|
|||
// but because we're calling the function directly, we need to set them manually.
|
||||
ctx.Params = gin.Params{
|
||||
gin.Param{
|
||||
Key: emoji.EmojiIDKey,
|
||||
Key: apiutil.IDKey,
|
||||
Value: targetEmoji.ID,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue