Skip to content

Commit

Permalink
fix(validations): fix named export
Browse files Browse the repository at this point in the history
As community may sometimes be null, I edited the
isDisputeSolver function ( in previous commit ) to accept null,
so we don't have to do a null check over it.
  • Loading branch information
Mersho committed Oct 31, 2023
1 parent d0930ac commit e8436f2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions bot/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IOrder } from "../models/order";
import { Telegraf } from "telegraf";

const { parsePaymentRequest } = require('invoices');
const { ObjectId } = require('mongoose').Types;
import { Types } from 'mongoose';
import * as messages from './messages';
import { Order, User, Community } from '../models';
import { isIso4217, isDisputeSolver } from '../util';
Expand Down Expand Up @@ -94,7 +94,6 @@ const validateAdmin = async (ctx: MainContext, id?: string) => {
if (user.default_community_id)
community = await Community.findOne({ _id: user.default_community_id });

if (community === null) throw Error("Community was not found in DB");
const isSolver = isDisputeSolver(community, user);

if (!user.admin && !isSolver)
Expand Down Expand Up @@ -593,7 +592,7 @@ const validateParams = async (ctx: MainContext, paramNumber: number, errOutputSt

const validateObjectId = async (ctx: MainContext, id: string) => {
try {
if (!ObjectId.isValid(id)) {
if (!Types.ObjectId.isValid(id)) {
await messages.notValidIdMessage(ctx);
return false;
}
Expand Down Expand Up @@ -647,7 +646,7 @@ const isBannedFromCommunity = async (user: UserDocument, communityId: string) =>
}
};

module.exports = {
export {
validateSellOrder,
validateBuyOrder,
validateUser,
Expand Down

0 comments on commit e8436f2

Please sign in to comment.