Fix reliability telegram notifications

This commit is contained in:
Reckless_Satoshi 2023-01-31 10:58:11 -08:00
parent afb7566e50
commit 0c7e1ae021
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
3 changed files with 5 additions and 18 deletions

View File

@ -58,23 +58,6 @@ class Telegram:
user.profile.save()
return
# def welcome(self, user):
# 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'Hola {user.username}, te enviaré un mensaje cuando tu orden con ID {str(order.id)} haya sido tomada.'
# else:
# text = f"Hey {user.username}, I will send you a message when someone takes your order with ID {str(order.id)}."
# self.send_message(user, text)
# user.profile.telegram_welcomed = True
# user.profile.save()
# return
def order_taken_confirmed(self, order):
if order.maker.profile.telegram_enabled:
lang = order.maker.profile.telegram_lang_code

View File

@ -299,7 +299,10 @@ def send_message(order_id, message):
from api.models import Order
order = Order.objects.get(id=order_id)
if not order.maker.profile.telegram_enabled:
taker_enabled = (
False if order.taker is None else order.taker.profile.telegram_enabled
)
if not (order.maker.profile.telegram_enabled or taker_enabled):
return
from api.messages import Telegram

View File

@ -751,6 +751,7 @@ class UserView(APIView):
user.profile.save()
context = {**context, **Telegram.get_context(user)}
context["public_key"] = user.profile.public_key
context["encrypted_private_key"] = user.profile.encrypted_private_key
context["wants_stealth"] = user.profile.wants_stealth