notification manager
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import Q
|
||||
|
||||
from daemons.management.commands.bot import bot
|
||||
from SprintLib.queue import notify
|
||||
from Main.models import Friendship
|
||||
from SprintLib.BaseView import BaseView
|
||||
from SprintLib.language import languages
|
||||
@@ -46,22 +46,17 @@ class AccountView(BaseView):
|
||||
).first()
|
||||
if friendship is None:
|
||||
Friendship.objects.create(from_user=self.request.user, to_user=self.context["account"])
|
||||
if self.context["account"].userinfo.notification_friends:
|
||||
bot.send_message(self.context["account"].userinfo.telegram_chat_id, f"Пользователь {self.request.user.username} хочет добавить тебя в друзья")
|
||||
notify(self.context['account'], 'friends', f"Пользователь {self.request.user.username} хочет добавить тебя в друзья")
|
||||
elif friendship.verified or friendship.from_user == self.request.user:
|
||||
friendship.delete()
|
||||
else:
|
||||
if self.request.POST["to_do"] == "yes":
|
||||
friendship.verified = True
|
||||
friendship.save()
|
||||
if self.context["account"].userinfo.notification_friends:
|
||||
bot.send_message(self.context["account"].userinfo.telegram_chat_id,
|
||||
f"Пользователь {self.request.user.username} добавил тебя в друзья")
|
||||
notify(self.context['account'], 'friends', f"Пользователь {self.request.user.username} добавил тебя в друзья")
|
||||
else:
|
||||
friendship.delete()
|
||||
if self.context["account"].userinfo.notification_friends:
|
||||
bot.send_message(self.context["account"].userinfo.telegram_chat_id,
|
||||
f"Пользователь {self.request.user.username} отклонил твою заявку")
|
||||
notify(self.context['account'], 'friends', f"Пользователь {self.request.user.username} отклонил твою заявку")
|
||||
return "/account?username=" + self.request.GET["username"]
|
||||
|
||||
def post_upload_photo(self):
|
||||
|
@@ -1,10 +1,11 @@
|
||||
from django.contrib.auth import login
|
||||
|
||||
from daemons.management.commands.bot import bot
|
||||
from SprintLib.BaseView import BaseView
|
||||
from django.contrib.auth.models import User
|
||||
from random import randrange
|
||||
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from SprintLib.BaseView import BaseView
|
||||
from SprintLib.queue import notify
|
||||
|
||||
|
||||
class SendCodeView(BaseView):
|
||||
endpoint = "send_code"
|
||||
@@ -20,9 +21,7 @@ class SendCodeView(BaseView):
|
||||
code = randrange(10000, 100000)
|
||||
user.userinfo.code = code
|
||||
user.userinfo.save()
|
||||
bot.send_message(
|
||||
user.userinfo.telegram_chat_id, "Код для входа в сервис: " + str(code)
|
||||
)
|
||||
notify(user, "any", "Код для входа в сервис: " + str(code))
|
||||
return {"success": True, "message": "Код отправлен"}
|
||||
|
||||
def post_check(self):
|
||||
|
Reference in New Issue
Block a user