mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
Avoid giving new robot to a user who is expecting still a payment
This commit is contained in:
parent
5d4e3c5718
commit
b39529d91e
@ -1,6 +1,7 @@
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
from api.lightning.node import LNNode
|
||||
from django.db.models import Q
|
||||
|
||||
from api.models import Order, LNPayment, MarketTick, User, Currency
|
||||
from decouple import config
|
||||
@ -30,7 +31,8 @@ FIAT_EXCHANGE_DURATION = int(config('FIAT_EXCHANGE_DURATION'))
|
||||
|
||||
class Logics():
|
||||
|
||||
def validate_already_maker_or_taker(user):
|
||||
@classmethod
|
||||
def validate_already_maker_or_taker(cls, user):
|
||||
'''Validates if a use is already not part of an active order'''
|
||||
|
||||
active_order_status = [Order.Status.WFB, Order.Status.PUB, Order.Status.TAK,
|
||||
@ -45,6 +47,14 @@ class Logics():
|
||||
queryset = Order.objects.filter(taker=user, status__in=active_order_status)
|
||||
if queryset.exists():
|
||||
return False, {'bad_request':'You are already taker of an active order'}, queryset[0]
|
||||
|
||||
# Edge case when the user is in an order that is failing payment and he is the buyer
|
||||
queryset = Order.objects.filter( Q(maker=user) | Q(taker=user), status__in=Order.Status.FAI)
|
||||
if queryset.exists():
|
||||
order = queryset[0]
|
||||
if cls.is_buyer(order, user):
|
||||
return False, {'bad_request':'You are still pending a payment from a recent order'}, order
|
||||
|
||||
return True, None, None
|
||||
|
||||
def validate_order_size(order):
|
||||
|
@ -303,12 +303,11 @@ export default class OrderPage extends Component {
|
||||
aria-describedby="inactive-maker-description"
|
||||
>
|
||||
<DialogTitle id="inactive-maker-dialog-title">
|
||||
{"The maker is inactive"}
|
||||
{"The maker is away"}
|
||||
</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="cancel-dialog-description">
|
||||
The maker seems to be away. You risk
|
||||
wasting your time.
|
||||
By taking this order you risk wasting your time.
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
|
@ -361,6 +361,8 @@ export default class TradeBox extends Component {
|
||||
|
||||
<Grid container spacing={1}>
|
||||
<Grid item xs={12} align="center">
|
||||
{/* Make confirmation sound for HTLC received. */}
|
||||
<this.Sound soundFileName="locked-invoice"/>
|
||||
<Typography color="primary" component="subtitle1" variant="subtitle1">
|
||||
<b> Submit a LN invoice for {pn(this.props.data.invoice_amount)} Sats </b>
|
||||
</Typography>
|
||||
|
Loading…
Reference in New Issue
Block a user