- заменен статус 200 на 500 в ошибках
This commit is contained in:
Danil Solovyov 2022-11-21 21:59:50 +05:00
parent fb5e03d888
commit 7d3df1ae95
2 changed files with 14 additions and 5 deletions

@ -21,6 +21,7 @@ type ReqAmoSaveToken struct {
State string `json:"state" schema:"state"`
FromWidget string `json:"from_widget" schema:"from_widget"`
Referer string `json:"referer" schema:"referer"`
Platform string `json:"platform" schema:"platform"` // Вообще без понятия что это
}
func (h *Handlers) AmoSaveToken(w http.ResponseWriter, r *http.Request) {
@ -106,6 +107,7 @@ type RespAmoState struct {
GenCount int `json:"gen_count"`
AuthYandexUrl string `json:"auth_yandex_url"`
AuthGoogleUrl string `json:"auth_google_url"`
AuthAmoUrl string `json:"auth_amo_url"`
Storages map[string]interface{} `json:"storages"`
Visibility []int64 `json:"visibility"`
Creation []int64 `json:"creation"`
@ -153,10 +155,17 @@ func (h *Handlers) AmoState(w http.ResponseWriter, r *http.Request, redirectUrn
return
}
authAmoUrl, err := h.Amo.GenerateOAuthUrl(amoData.UserID, redirectUri)
if err != nil {
h.reportError(w, err, http.StatusInternalServerError)
return
}
resp := RespAmoState{
GenCount: 97,
AuthYandexUrl: authYandexUrl,
AuthGoogleUrl: authGoogleUrl,
AuthAmoUrl: authAmoUrl,
Storages: storages,
Visibility: amoData.AccessRules.Visibility,
Creation: amoData.AccessRules.Creation,

@ -53,7 +53,7 @@ func (h *Handlers) GeneratorByAmoLead(w http.ResponseWriter, r *http.Request) {
lead, err := amoClient.GetLeadById(leadId)
if err != nil {
h.reportError(w, err, 200)
h.reportError(w, err, http.StatusInternalServerError)
return
}
@ -252,13 +252,13 @@ func (h *Handlers) GeneratorByAmoWebhook(w http.ResponseWriter, r *http.Request)
reqBody, err := io.ReadAll(r.Body)
if err != nil {
h.reportError(w, err, 200)
h.reportError(w, err, http.StatusBadRequest)
return
}
p, err := url.ParseQuery(string(reqBody))
if err != nil {
h.reportError(w, err, 200)
h.reportError(w, err, http.StatusBadRequest)
return
}
@ -269,7 +269,7 @@ func (h *Handlers) GeneratorByAmoWebhook(w http.ResponseWriter, r *http.Request)
// Запрашиваем данные по аккаунту
amoData, err := h.dal.Amo.GetByAccountID(r.Context(), accId)
if err != nil {
h.reportError(w, err, 200)
h.reportError(w, err, http.StatusInternalServerError)
return
}
@ -282,7 +282,7 @@ func (h *Handlers) GeneratorByAmoWebhook(w http.ResponseWriter, r *http.Request)
lead, err := amoClient.GetLeadById(leadId)
if err != nil {
h.reportError(w, err, 200)
h.reportError(w, err, http.StatusInternalServerError)
return
}