Skip to content

Commit

Permalink
Merge pull request #1506 from RoboSats/revert-1429-store-status-notif…
Browse files Browse the repository at this point in the history
…ications

Revert "Store status notifications"
  • Loading branch information
KoalaSat authored Oct 1, 2024
2 parents 0749d31 + 7d7a3a3 commit 9fc7087
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 181 deletions.
6 changes: 6 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
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_notification

admin.site.unregister(Group)
admin.site.unregister(User)
Expand Down Expand Up @@ -163,6 +164,9 @@ def cancel_public_order(self, request, queryset):
f"Order {order.id} successfully closed",
messages.SUCCESS,
)
send_notification.delay(
order_id=order.id, message="coordinator_cancelled"
)
else:
self.message_user(
request,
Expand Down Expand Up @@ -206,6 +210,7 @@ def maker_wins(self, request, queryset):
f"Dispute of order {order.id} solved successfully on favor of the maker",
messages.SUCCESS,
)
send_notification.delay(order_id=order.id, message="dispute_closed")

else:
self.message_user(
Expand Down Expand Up @@ -244,6 +249,7 @@ def taker_wins(self, request, queryset):
f"Dispute of order {order.id} solved successfully on favor of the taker",
messages.SUCCESS,
)
send_notification.delay(order_id=order.id, message="dispute_closed")

else:
self.message_user(
Expand Down
8 changes: 4 additions & 4 deletions api/lightning/cln.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,10 @@ def handle_response():
]
)

order.update_status(Order.Status.FAI)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.FAI)
)
order.update_status(Order.Status.FAI)
order.save(update_fields=["expires_at"])

print(
Expand All @@ -646,10 +646,10 @@ def handle_response():
)
lnpayment.preimage = response.payment_preimage.hex()
lnpayment.save(update_fields=["status", "fee", "preimage"])
order.update_status(Order.Status.SUC)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.SUC)
)
order.update_status(Order.Status.SUC)
order.save(update_fields=["expires_at"])

order.log(
Expand Down Expand Up @@ -697,10 +697,10 @@ def handle_response():
]
)

order.update_status(Order.Status.FAI)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.FAI)
)
order.update_status(Order.Status.FAI)
order.save(update_fields=["expires_at"])

print(
Expand Down Expand Up @@ -737,10 +737,10 @@ def handle_response():
"in_flight",
]
)
order.update_status(Order.Status.FAI)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.FAI)
)
order.update_status(Order.Status.FAI)
order.save(update_fields=["expires_at"])

order.log(
Expand Down
7 changes: 4 additions & 3 deletions api/lightning/lnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,11 @@ def handle_response(response, was_in_transit=False):
]
)

order.update_status(Order.Status.FAI)

order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.FAI)
)
order.update_status(Order.Status.FAI)
order.save(update_fields=["expires_at"])

str_failure_reason = cls.payment_failure_context[
Expand All @@ -624,10 +625,10 @@ def handle_response(response, was_in_transit=False):
lnpayment.preimage = response.payment_preimage
lnpayment.save(update_fields=["status", "fee", "preimage"])

order.update_status(Order.Status.SUC)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.SUC)
)
order.update_status(Order.Status.SUC)
order.save(update_fields=["expires_at"])

order.log(
Expand Down Expand Up @@ -670,10 +671,10 @@ def handle_response(response, was_in_transit=False):
update_fields=["status", "last_routing_time", "in_flight"]
)

order.update_status(Order.Status.FAI)
order.expires_at = timezone.now() + timedelta(
seconds=order.t_to_expire(Order.Status.FAI)
)
order.update_status(Order.Status.FAI)
order.save(update_fields=["expires_at"])

order.log(
Expand Down
Loading

0 comments on commit 9fc7087

Please sign in to comment.