if state == '' return 400
This commit is contained in:
parent
aca3b0bdc2
commit
dc720b8bc8
@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"net/http"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,7 +19,11 @@ func (c *WebhookController) WebhookCreate(ctx *fiber.Ctx) error {
|
|||||||
noAccess := ctx.Query("error")
|
noAccess := ctx.Query("error")
|
||||||
|
|
||||||
if noAccess != "" {
|
if noAccess != "" {
|
||||||
return ctx.Status(http.StatusForbidden).SendString("Access denied")
|
return ctx.Status(fiber.StatusForbidden).SendString("Access denied")
|
||||||
|
}
|
||||||
|
|
||||||
|
if state == "" {
|
||||||
|
return ctx.Status(fiber.StatusBadRequest).SendString("State don't be empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
accountID, _, err := tools.DeserializeProtobufMessage(state)
|
accountID, _, err := tools.DeserializeProtobufMessage(state)
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
"penahub.gitlab.yandexcloud.net/backend/quiz/common.git/model"
|
||||||
@ -694,14 +693,14 @@ func (a *Amo) createPart(uploadData models.UploadSession, file *os.File) (*model
|
|||||||
return nil, fmt.Errorf("request failed: %v", errs[0])
|
return nil, fmt.Errorf("request failed: %v", errs[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if statusCode != http.StatusOK && statusCode != http.StatusAccepted {
|
if statusCode != fiber.StatusOK && statusCode != fiber.StatusAccepted {
|
||||||
return nil, fmt.Errorf("failed to upload part file to amo, status: %d, respBody: %s", statusCode, string(resBody))
|
return nil, fmt.Errorf("failed to upload part file to amo, status: %d, respBody: %s", statusCode, string(resBody))
|
||||||
}
|
}
|
||||||
|
|
||||||
start = end
|
start = end
|
||||||
remainingSize -= partSize
|
remainingSize -= partSize
|
||||||
|
|
||||||
if statusCode == http.StatusAccepted {
|
if statusCode == fiber.StatusAccepted {
|
||||||
var next struct {
|
var next struct {
|
||||||
NextUrl string `json:"next_url"`
|
NextUrl string `json:"next_url"`
|
||||||
SessionID int `json:"session_id"`
|
SessionID int `json:"session_id"`
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
@ -49,7 +48,7 @@ func (c *Client) GenerateAmocrmAuthURL(accountID string) (string, error) {
|
|||||||
return "", fmt.Errorf("request GenerateAmocrmAuthURL failed: %v", errs[0])
|
return "", fmt.Errorf("request GenerateAmocrmAuthURL failed: %v", errs[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
if statusCode != http.StatusOK {
|
if statusCode != fiber.StatusOK {
|
||||||
errorMessage := fmt.Sprintf("received an incorrect response from GenerateAmocrmAuthURL: %d", statusCode)
|
errorMessage := fmt.Sprintf("received an incorrect response from GenerateAmocrmAuthURL: %d", statusCode)
|
||||||
c.logger.Error(errorMessage, zap.Int("status", statusCode))
|
c.logger.Error(errorMessage, zap.Int("status", statusCode))
|
||||||
return "", fmt.Errorf(errorMessage)
|
return "", fmt.Errorf(errorMessage)
|
||||||
|
Loading…
Reference in New Issue
Block a user