mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-09 06:00:12 +02:00
fixed offers creation
This commit is contained in:
parent
5068cab40a
commit
9cca2e1ede
@ -1,4 +1,8 @@
|
||||
import { ForbiddenException, Injectable } from '@nestjs/common';
|
||||
import {
|
||||
ForbiddenException,
|
||||
ImATeapotException,
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { checkUserHasAccount, checkuserIsAdmin } from 'src/utils/checkUser';
|
||||
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;
|
||||
if (buyer.dollarAvailables < price) {
|
||||
throw new ForbiddenException(
|
||||
|
Loading…
x
Reference in New Issue
Block a user