From b9fe3b8d55104617dcd76d0284291d91fcb3de90 Mon Sep 17 00:00:00 2001 From: Nareshkumar Rao <629990+naresh97@users.noreply.github.com> Date: Thu, 12 Aug 2021 23:56:06 +0200 Subject: [PATCH] bugfix: issue when getting covid positivity of new user --- src/db/models/User.helper.ts | 1 + src/routes/CovidRoute.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/db/models/User.helper.ts b/src/db/models/User.helper.ts index 7e6bb8c..9a1df10 100644 --- a/src/db/models/User.helper.ts +++ b/src/db/models/User.helper.ts @@ -39,6 +39,7 @@ export async function getUserCovidPositivity( ): Promise { const user = await getUserByTelegramID(telegramID); if (!user) throw new Error("User not found"); + if (!user.infectionDate) return false; const infectionDuration = new Date().getTime() - user.infectionDate.getTime(); if (infectionDuration > 60 * 60 * 24 * 14 * 1000) { await setUserCovidPositivity(telegramID, false); diff --git a/src/routes/CovidRoute.ts b/src/routes/CovidRoute.ts index d2c9584..9299fca 100644 --- a/src/routes/CovidRoute.ts +++ b/src/routes/CovidRoute.ts @@ -27,7 +27,7 @@ export async function CovidRoute(req: CovidRouteRequest, res: Response) { } } catch (error) { res - .send(500) + .status(500) .send({ error: error instanceof Error ? error.message : "Error" }); } }