Browse Source
Merge pull request #13 from naresh97/development
bugfix: issue when getting covid positivity of new user
main
Nareshkumar Rao
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
2 additions and
1 deletions
-
src/db/models/User.helper.ts
-
src/routes/CovidRoute.ts
|
@ -39,6 +39,7 @@ export async function getUserCovidPositivity( |
|
|
): Promise<boolean> { |
|
|
): Promise<boolean> { |
|
|
const user = await getUserByTelegramID(telegramID); |
|
|
const user = await getUserByTelegramID(telegramID); |
|
|
if (!user) throw new Error("User not found"); |
|
|
if (!user) throw new Error("User not found"); |
|
|
|
|
|
if (!user.infectionDate) return false; |
|
|
const infectionDuration = new Date().getTime() - user.infectionDate.getTime(); |
|
|
const infectionDuration = new Date().getTime() - user.infectionDate.getTime(); |
|
|
if (infectionDuration > 60 * 60 * 24 * 14 * 1000) { |
|
|
if (infectionDuration > 60 * 60 * 24 * 14 * 1000) { |
|
|
await setUserCovidPositivity(telegramID, false); |
|
|
await setUserCovidPositivity(telegramID, false); |
|
|
|
@ -27,7 +27,7 @@ export async function CovidRoute(req: CovidRouteRequest, res: Response) { |
|
|
} |
|
|
} |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
res |
|
|
res |
|
|
.send(500) |
|
|
|
|
|
|
|
|
.status(500) |
|
|
.send({ error: error instanceof Error ? error.message : "Error" }); |
|
|
.send({ error: error instanceof Error ? error.message : "Error" }); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|