From e5bafe2027374861c3bbca84ab1e8027b1c1d03e Mon Sep 17 00:00:00 2001 From: Mehrshad Date: Wed, 13 Sep 2023 13:58:27 +0330 Subject: [PATCH] refactor: correcting a bad practice --- bot/start.ts | 16 ++++++++-------- bot/validations.ts | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bot/start.ts b/bot/start.ts index 4d69c7d9..ad84e6b8 100644 --- a/bot/start.ts +++ b/bot/start.ts @@ -210,7 +210,7 @@ const initialize = (botToken: string, options: Partial'); if (!val) return; let config = await Config.findOne(); - if (!config) { + if (config === null) { config = new Config(); } config.maintenance = false; @@ -284,7 +284,7 @@ const initialize = (botToken: string, options: Partial { const user = await User.findOne({ tg_id: tgUserId }); // If the user never started the bot we can't send messages // to that user, so we do nothing - if (!user) return; + if (user === null) return; if (!user.admin) return await messages.notAuthorized(ctx, tgUserId.toString()); @@ -88,7 +88,7 @@ const validateAdmin = async (ctx: MainContext, id?: string) => { const user = await User.findOne({ tg_id: tgUserId }); // If the user never started the bot we can't send messages // to that user, so we do nothing - if (!user) return; + if (user === null) return; let community = null; if (user.default_community_id) @@ -475,7 +475,7 @@ const validateReleaseOrder = async (ctx: MainContext, user: UserDocument, orderI } order = await Order.findOne(where); - if (!order) { + if (order === null) { await messages.notActiveOrderMessage(ctx); return false; } @@ -499,7 +499,7 @@ const validateDisputeOrder = async (ctx: MainContext, user: UserDocument, orderI const order = await Order.findOne(where); - if (!order) { + if (order === null) { await messages.notActiveOrderMessage(ctx); return false; } @@ -524,7 +524,7 @@ const validateFiatSentOrder = async (ctx: MainContext, user: UserDocument, order where._id = orderId; } const order = await Order.findOne(where); - if (!order) { + if (order === null) { await messages.notActiveOrderMessage(ctx); return false; }