Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Aug 26, 2024
1 parent 1ef38e2 commit cc0310d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
4 changes: 0 additions & 4 deletions api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from api.logics import Logics
from api.models import Currency, LNPayment, MarketTick, OnchainPayment, Order, Robot
from api.utils import objects_to_hyperlinks
from api.tasks import send_status_notification

admin.site.unregister(Group)
admin.site.unregister(User)
Expand Down Expand Up @@ -164,9 +163,6 @@ def cancel_public_order(self, request, queryset):
f"Order {order.id} successfully closed",
messages.SUCCESS,
)
send_status_notification.delay(
order_id=order.id, message="coordinator_cancelled"
)
else:
self.message_user(
request,
Expand Down
4 changes: 1 addition & 3 deletions api/logics.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,6 @@ def move_state_updated_payout_method(cls, order):

# If the escrow is locked move to Chat.
elif order.trade_escrow.status == LNPayment.Status.LOCKED:
order.update_status(Order.Status.CHA)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.CHA)
)
Expand Down Expand Up @@ -1437,7 +1436,6 @@ def trade_escrow_received(order):
order.update_status(Order.Status.WFI)
# If status is 'Waiting for invoice' move to Chat
elif order.status == Order.Status.WFE:
order.update_status(Order.Status.CHA)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.CHA)
)
Expand Down Expand Up @@ -1708,9 +1706,9 @@ def undo_confirm_fiat_sent(cls, order, user):
return False, {
"bad_request": "Only orders in Chat and with fiat sent confirmed can be reverted."
}
order.update_status(Order.Status.CHA)
order.is_fiat_sent = False
order.reverted_fiat_sent = True
order.update_status(Order.Status.CHA)
order.save(update_fields=["is_fiat_sent", "reverted_fiat_sent"])

order.log(
Expand Down
27 changes: 26 additions & 1 deletion tests/test_trade_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,35 @@ def test_trade_to_submitted_invoice(self):
trade.publish_order()
trade.take_order()
trade.lock_taker_bond()

maker_nick = read_file(f"tests/robots/{trade.maker_index}/nickname")
taker_nick = read_file(f"tests/robots/{trade.taker_index}/nickname")

maker_headers = trade.get_robot_auth(trade.maker_index)
response = self.client.get(reverse("notifications"), **maker_headers)
self.assertResponse(response)
notifications_data = list(response.json())
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
# Does not receive notification because user is online
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {maker_nick}, your order was taken by {taker_nick}!🥳",
)

trade.lock_escrow(trade.taker_index)
trade.submit_payout_invoice(trade.maker_index)

maker_headers = trade.get_robot_auth(trade.maker_index)
response = self.client.get(reverse("notifications"), **maker_headers)
self.assertResponse(response)
notifications_data = list(response.json())
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
# Does not receive notification because user is online
self.assertEqual(
notifications_data[0]["title"],
"",
)

data = trade.response.json()

self.assertEqual(trade.response.status_code, 200)
Expand All @@ -571,7 +597,6 @@ def test_trade_to_submitted_invoice(self):
self.assertEqual(data["status_message"], Order.Status(Order.Status.CHA).label)
self.assertFalse(data["is_fiat_sent"])

maker_headers = trade.get_robot_auth(trade.maker_index)
maker_nick = read_file(f"tests/robots/{trade.maker_index}/nickname")
response = self.client.get(reverse("notifications"), **maker_headers)
self.assertResponse(response)
Expand Down

0 comments on commit cc0310d

Please sign in to comment.