diff --git a/api/messages.py b/api/messages.py index 6b517574..d666ef91 100644 --- a/api/messages.py +++ b/api/messages.py @@ -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 diff --git a/api/tasks.py b/api/tasks.py index 700db183..9c72fa1f 100644 --- a/api/tasks.py +++ b/api/tasks.py @@ -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 diff --git a/api/views.py b/api/views.py index d32dea19..40e06e5f 100644 --- a/api/views.py +++ b/api/views.py @@ -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