mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 02:21:35 +00:00
Telegram notification only when taker bond is locked
This commit is contained in:
parent
b4001653f2
commit
6373957774
@ -130,7 +130,7 @@ class Logics:
|
||||
order.expires_at = timezone.now() + timedelta(
|
||||
seconds=Order.t_to_expire[Order.Status.TAK])
|
||||
order.save()
|
||||
send_message.delay(order.id,'order_taken')
|
||||
# send_message.delay(order.id,'order_taken') # Too spammy
|
||||
return True, None
|
||||
|
||||
def is_buyer(order, user):
|
||||
@ -215,7 +215,7 @@ class Logics:
|
||||
elif order.status == Order.Status.TAK:
|
||||
cls.cancel_bond(order.taker_bond)
|
||||
cls.kick_taker(order)
|
||||
send_message.delay(order.id,'taker_expired_b4bond')
|
||||
# send_message.delay(order.id,'taker_expired_b4bond') # Too spammy
|
||||
return True
|
||||
|
||||
elif order.status == Order.Status.WF2:
|
||||
@ -578,7 +578,7 @@ class Logics:
|
||||
# adds a timeout penalty
|
||||
cls.cancel_bond(order.taker_bond)
|
||||
cls.kick_taker(order)
|
||||
send_message.delay(order.id,'taker_canceled_b4bond')
|
||||
# send_message.delay(order.id,'taker_canceled_b4bond') # too spammy
|
||||
return True, None
|
||||
|
||||
# 4) When taker or maker cancel after bond (before escrow)
|
||||
@ -769,6 +769,7 @@ class Logics:
|
||||
MarketTick.log_a_tick(order)
|
||||
except:
|
||||
pass
|
||||
send_message.delay(order.id,'order_taken_confirmed')
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
|
@ -34,7 +34,6 @@ class Telegram():
|
||||
chat_id = user.profile.telegram_chat_id
|
||||
message_url = f'https://api.telegram.org/bot{bot_token}/sendMessage?chat_id={chat_id}&text={text}'
|
||||
|
||||
# telegram messaging is atm inserted dangerously in the logics module
|
||||
# if it fails, it should keep trying
|
||||
while True:
|
||||
try:
|
||||
@ -47,7 +46,6 @@ class Telegram():
|
||||
lang = user.profile.telegram_lang_code
|
||||
|
||||
# In weird cases the order cannot be found (e.g. it is cancelled)
|
||||
|
||||
queryset = Order.objects.filter(maker=user)
|
||||
order = queryset.last()
|
||||
|
||||
@ -77,6 +75,22 @@ class Telegram():
|
||||
self.send_message(user, text)
|
||||
return
|
||||
|
||||
def order_taken_confirmed(self, order):
|
||||
user = order.maker
|
||||
if not user.profile.telegram_enabled:
|
||||
return
|
||||
|
||||
lang = user.profile.telegram_lang_code
|
||||
taker_nick = order.taker.username
|
||||
site = config('HOST_NAME')
|
||||
if lang == 'es':
|
||||
text = f'¡Tu orden con ID {order.id} ha sido tomada por {taker_nick}!🥳 El tomador ya ha bloqueado su fianza. Visita http://{site}/order/{order.id} para continuar.'
|
||||
else:
|
||||
text = f'Your order with ID {order.id} was taken by {taker_nick}!🥳 The taker bond has been already locked. Visit http://{site}/order/{order.id} to proceed with the trade.'
|
||||
|
||||
self.send_message(user, text)
|
||||
return
|
||||
|
||||
def order_expired_untaken(self, order):
|
||||
user = order.maker
|
||||
if not user.profile.telegram_enabled:
|
||||
|
@ -212,4 +212,6 @@ def send_message(order_id, message):
|
||||
elif message == 'order_published':
|
||||
telegram.order_published(order)
|
||||
|
||||
elif message == 'order_taken_confirmed':
|
||||
telegram.order_taken_confirmed(order)
|
||||
return
|
Loading…
Reference in New Issue
Block a user