From 0e10470c0286d136c5b4a0235f1f36de209d02ba Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Thu, 6 Oct 2022 13:29:55 -0700 Subject: [PATCH] Revert "break CH fetch" This reverts commit 5dd395918f0658b6bd8ba69dba9cd97751c2c9a9. --- lib/session.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/session.js b/lib/session.js index dd196aaa..f4498596 100644 --- a/lib/session.js +++ b/lib/session.js @@ -2,6 +2,7 @@ import { uuid } from 'lib/crypto'; import redis, { DELETED } from 'lib/redis'; import { getClientInfo, getJsonBody } from 'lib/request'; import { parseToken } from 'next-basics'; +import { getWebsiteByUuid } from 'queries'; import { validate } from 'uuid'; export async function getSession(req) { @@ -35,16 +36,14 @@ export async function getSession(req) { websiteId = Number(await redis.client.get(`website:${website_uuid}`)); } - // // Check database if does not exists in Redis - // if (!websiteId) { - // const website = await getWebsiteByUuid(website_uuid); - // websiteId = website ? website.website_id : null; - // } + // Check database if does not exists in Redis + if (!websiteId) { + const website = await getWebsiteByUuid(website_uuid); + websiteId = website ? website.website_id : null; + } if (!websiteId || websiteId === DELETED) { - throw new Error( - `Website not found: ${website_uuid} : ${process.env.REDIS_URL} : ${process.env.CLICKHOUSE_URL}`, - ); + throw new Error(`Website not found: ${website_uuid}`); } const { userAgent, browser, os, ip, country, device } = await getClientInfo(req, payload);