mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-18 16:53:16 +00:00
Fix message the order is public for avatars that are re-used
This commit is contained in:
@ -619,6 +619,7 @@ class Logics:
|
|||||||
order.expires_at = order.created_at + timedelta(
|
order.expires_at = order.created_at + timedelta(
|
||||||
seconds=Order.t_to_expire[Order.Status.PUB])
|
seconds=Order.t_to_expire[Order.Status.PUB])
|
||||||
order.save()
|
order.save()
|
||||||
|
send_message.delay(order.id,'order_published')
|
||||||
return
|
return
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -2,6 +2,7 @@ from decouple import config
|
|||||||
from secrets import token_urlsafe
|
from secrets import token_urlsafe
|
||||||
from api.models import Order
|
from api.models import Order
|
||||||
from api.utils import get_tor_session
|
from api.utils import get_tor_session
|
||||||
|
import time
|
||||||
|
|
||||||
class Telegram():
|
class Telegram():
|
||||||
''' Simple telegram messages by requesting to API'''
|
''' Simple telegram messages by requesting to API'''
|
||||||
@ -126,9 +127,9 @@ class Telegram():
|
|||||||
|
|
||||||
lang = user.profile.telegram_lang_code
|
lang = user.profile.telegram_lang_code
|
||||||
if lang == 'es':
|
if lang == 'es':
|
||||||
text = f'El tomador ha cancelado antes de bloquear su fianza. Tu orden con ID {order.id} vuelve a ser pública.'
|
text = f'El tomador ha cancelado antes de bloquear su fianza.'
|
||||||
else:
|
else:
|
||||||
text = f'The taker has canceled before locking the bond. Your order with ID {order.id} is once again public in the order book.'
|
text = f'The taker has canceled before locking the bond.'
|
||||||
|
|
||||||
self.send_message(user, text)
|
self.send_message(user, text)
|
||||||
return
|
return
|
||||||
@ -140,9 +141,31 @@ class Telegram():
|
|||||||
|
|
||||||
lang = user.profile.telegram_lang_code
|
lang = user.profile.telegram_lang_code
|
||||||
if lang == 'es':
|
if lang == 'es':
|
||||||
text = f'El tomador no ha bloqueado la fianza a tiempo. Tu orden con ID {order.id} vuelve a ser pública.'
|
text = f'El tomador no ha bloqueado la fianza a tiempo.'
|
||||||
else:
|
else:
|
||||||
text = f'The taker has not locked the bond in time. Your order with ID {order.id} is once again public in the order book.'
|
text = f'The taker has not locked the bond in time.'
|
||||||
|
|
||||||
self.send_message(user, text)
|
self.send_message(user, text)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def order_published(self, order):
|
||||||
|
|
||||||
|
time.sleep(1) # Just so this message always arrives after the previous two
|
||||||
|
|
||||||
|
user = order.maker
|
||||||
|
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()
|
||||||
|
|
||||||
|
print(str(order.id))
|
||||||
|
if lang == 'es':
|
||||||
|
text = f'Tu orden con ID {str(order.id)} es pública en el libro de ordenes.'
|
||||||
|
else:
|
||||||
|
text = f"Your order with ID {str(order.id)} is public in the order book."
|
||||||
|
self.send_message(user, text)
|
||||||
|
user.profile.telegram_welcomed = True
|
||||||
|
user.profile.save()
|
||||||
|
return
|
@ -182,4 +182,7 @@ def send_message(order_id, message):
|
|||||||
elif message == 'taker_canceled_b4bond':
|
elif message == 'taker_canceled_b4bond':
|
||||||
telegram.taker_canceled_b4bond(order)
|
telegram.taker_canceled_b4bond(order)
|
||||||
|
|
||||||
|
elif message == 'order_published':
|
||||||
|
telegram.order_published(order)
|
||||||
|
|
||||||
return
|
return
|
Reference in New Issue
Block a user