fixed offers creation

This commit is contained in:
Kevsl 2024-06-19 16:40:38 +02:00
parent 5068cab40a
commit 9cca2e1ede

View File

@ -1,4 +1,8 @@
import { ForbiddenException, Injectable } from '@nestjs/common'; import {
ForbiddenException,
ImATeapotException,
Injectable,
} from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service'; import { PrismaService } from '../prisma/prisma.service';
import { checkUserHasAccount, checkuserIsAdmin } from 'src/utils/checkUser'; import { checkUserHasAccount, checkuserIsAdmin } from 'src/utils/checkUser';
import { TradeDto } from './dto'; import { TradeDto } from './dto';
@ -80,6 +84,10 @@ export class TradeService {
}, },
}); });
if (seller.id === buyer.id) {
throw new ImATeapotException('Get the fuck outta here');
}
const price = crypto.value * offer.amount; const price = crypto.value * offer.amount;
if (buyer.dollarAvailables < price) { if (buyer.dollarAvailables < price) {
throw new ForbiddenException( throw new ForbiddenException(