if state == '' return 400

This commit is contained in:
Pavel 2024-08-13 11:23:32 +03:00 committed by skeris
parent aca3b0bdc2
commit dc720b8bc8
3 changed files with 8 additions and 7 deletions

@ -6,7 +6,6 @@ import (
"fmt"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
"net/http"
"strconv"
)
@ -20,7 +19,11 @@ func (c *WebhookController) WebhookCreate(ctx *fiber.Ctx) error {
noAccess := ctx.Query("error")
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)

@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"os"
"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])
}
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))
}
start = end
remainingSize -= partSize
if statusCode == http.StatusAccepted {
if statusCode == fiber.StatusAccepted {
var next struct {
NextUrl string `json:"next_url"`
SessionID int `json:"session_id"`

@ -5,7 +5,6 @@ import (
"fmt"
"github.com/gofiber/fiber/v2"
"go.uber.org/zap"
"net/http"
)
type Deps struct {
@ -49,7 +48,7 @@ func (c *Client) GenerateAmocrmAuthURL(accountID string) (string, error) {
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)
c.logger.Error(errorMessage, zap.Int("status", statusCode))
return "", fmt.Errorf(errorMessage)