Browse Source

bugfix: issue when getting covid positivity of new user

pull/13/head
Nareshkumar Rao 3 years ago
parent
commit
b9fe3b8d55
  1. 1
      src/db/models/User.helper.ts
  2. 2
      src/routes/CovidRoute.ts

1
src/db/models/User.helper.ts

@ -39,6 +39,7 @@ export async function getUserCovidPositivity(
): Promise<boolean> {
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);

2
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" });
}
}

Loading…
Cancel
Save