Changes:
- заменен статус 200 на 500 в ошибках
This commit is contained in:
parent
fb5e03d888
commit
7d3df1ae95
@ -21,6 +21,7 @@ type ReqAmoSaveToken struct {
|
|||||||
State string `json:"state" schema:"state"`
|
State string `json:"state" schema:"state"`
|
||||||
FromWidget string `json:"from_widget" schema:"from_widget"`
|
FromWidget string `json:"from_widget" schema:"from_widget"`
|
||||||
Referer string `json:"referer" schema:"referer"`
|
Referer string `json:"referer" schema:"referer"`
|
||||||
|
Platform string `json:"platform" schema:"platform"` // Вообще без понятия что это
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handlers) AmoSaveToken(w http.ResponseWriter, r *http.Request) {
|
func (h *Handlers) AmoSaveToken(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -106,6 +107,7 @@ type RespAmoState struct {
|
|||||||
GenCount int `json:"gen_count"`
|
GenCount int `json:"gen_count"`
|
||||||
AuthYandexUrl string `json:"auth_yandex_url"`
|
AuthYandexUrl string `json:"auth_yandex_url"`
|
||||||
AuthGoogleUrl string `json:"auth_google_url"`
|
AuthGoogleUrl string `json:"auth_google_url"`
|
||||||
|
AuthAmoUrl string `json:"auth_amo_url"`
|
||||||
Storages map[string]interface{} `json:"storages"`
|
Storages map[string]interface{} `json:"storages"`
|
||||||
Visibility []int64 `json:"visibility"`
|
Visibility []int64 `json:"visibility"`
|
||||||
Creation []int64 `json:"creation"`
|
Creation []int64 `json:"creation"`
|
||||||
@ -153,10 +155,17 @@ func (h *Handlers) AmoState(w http.ResponseWriter, r *http.Request, redirectUrn
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
authAmoUrl, err := h.Amo.GenerateOAuthUrl(amoData.UserID, redirectUri)
|
||||||
|
if err != nil {
|
||||||
|
h.reportError(w, err, http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
resp := RespAmoState{
|
resp := RespAmoState{
|
||||||
GenCount: 97,
|
GenCount: 97,
|
||||||
AuthYandexUrl: authYandexUrl,
|
AuthYandexUrl: authYandexUrl,
|
||||||
AuthGoogleUrl: authGoogleUrl,
|
AuthGoogleUrl: authGoogleUrl,
|
||||||
|
AuthAmoUrl: authAmoUrl,
|
||||||
Storages: storages,
|
Storages: storages,
|
||||||
Visibility: amoData.AccessRules.Visibility,
|
Visibility: amoData.AccessRules.Visibility,
|
||||||
Creation: amoData.AccessRules.Creation,
|
Creation: amoData.AccessRules.Creation,
|
||||||
|
@ -53,7 +53,7 @@ func (h *Handlers) GeneratorByAmoLead(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
lead, err := amoClient.GetLeadById(leadId)
|
lead, err := amoClient.GetLeadById(leadId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.reportError(w, err, 200)
|
h.reportError(w, err, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,13 +252,13 @@ func (h *Handlers) GeneratorByAmoWebhook(w http.ResponseWriter, r *http.Request)
|
|||||||
reqBody, err := io.ReadAll(r.Body)
|
reqBody, err := io.ReadAll(r.Body)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.reportError(w, err, 200)
|
h.reportError(w, err, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := url.ParseQuery(string(reqBody))
|
p, err := url.ParseQuery(string(reqBody))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.reportError(w, err, 200)
|
h.reportError(w, err, http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ func (h *Handlers) GeneratorByAmoWebhook(w http.ResponseWriter, r *http.Request)
|
|||||||
// Запрашиваем данные по аккаунту
|
// Запрашиваем данные по аккаунту
|
||||||
amoData, err := h.dal.Amo.GetByAccountID(r.Context(), accId)
|
amoData, err := h.dal.Amo.GetByAccountID(r.Context(), accId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.reportError(w, err, 200)
|
h.reportError(w, err, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ func (h *Handlers) GeneratorByAmoWebhook(w http.ResponseWriter, r *http.Request)
|
|||||||
|
|
||||||
lead, err := amoClient.GetLeadById(leadId)
|
lead, err := amoClient.GetLeadById(leadId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.reportError(w, err, 200)
|
h.reportError(w, err, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user