diff --git a/internal/controllers/webhook.go b/internal/controllers/webhook.go index 29b88ae..c88ad83 100644 --- a/internal/controllers/webhook.go +++ b/internal/controllers/webhook.go @@ -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) diff --git a/pkg/amoClient/amo.go b/pkg/amoClient/amo.go index c85c31a..1bd4d60 100644 --- a/pkg/amoClient/amo.go +++ b/pkg/amoClient/amo.go @@ -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"` diff --git a/pkg/pena-social-auth/client.go b/pkg/pena-social-auth/client.go index 0b64148..3f03863 100644 --- a/pkg/pena-social-auth/client.go +++ b/pkg/pena-social-auth/client.go @@ -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)