From 366cc19c1bcbac1b6a3ad6357014e0b08428b930 Mon Sep 17 00:00:00 2001 From: Alexander Gusman Date: Mon, 24 Jul 2023 09:59:03 +0300 Subject: [PATCH] fix(rest): correct status code for telegram check token --- backend/app/rest/api/rest_private.go | 2 +- backend/app/rest/api/rest_private_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/app/rest/api/rest_private.go b/backend/app/rest/api/rest_private.go index f7e9f6f5..0a7994e7 100644 --- a/backend/app/rest/api/rest_private.go +++ b/backend/app/rest/api/rest_private.go @@ -430,7 +430,7 @@ func (s *private) telegramSubscribeCtrl(w http.ResponseWriter, r *http.Request) var address, siteID string address, siteID, err := s.telegramService.CheckToken(queryToken, user.ID) if err != nil { - rest.SendErrorJSON(w, r, http.StatusInternalServerError, err, "can't set telegram for user", rest.ErrInternal) + rest.SendErrorJSON(w, r, http.StatusNotFound, err, "request is not verified yet", rest.ErrInternal) return } diff --git a/backend/app/rest/api/rest_private_test.go b/backend/app/rest/api/rest_private_test.go index df501003..e94155c9 100644 --- a/backend/app/rest/api/rest_private_test.go +++ b/backend/app/rest/api/rest_private_test.go @@ -1238,8 +1238,8 @@ func TestRest_TelegramNotification(t *testing.T) { body, err = io.ReadAll(resp.Body) require.NoError(t, err) require.NoError(t, resp.Body.Close()) - require.Equal(t, http.StatusInternalServerError, resp.StatusCode, string(body)) - require.Equal(t, `{"code":0,"details":"can't set telegram for user","error":"not verified"}`+"\n", string(body)) + require.Equal(t, http.StatusNotFound, resp.StatusCode, string(body)) + require.Equal(t, `{"code":0,"details":"request is not verified yet","error":"not verified"}`+"\n", string(body)) mockTlgrm.notVerified = false