сообщение с js отправляется но elif data["do"] == "finishScan": почему то не срабатывает.
async def receive(self, text_data):
logger.info(text_data)
data = json.loads(text_data)
logger.info(str(data))
if data["do"] == "startScan":
autoFriend = None
if data['autoFriend'] == "true":
autoFriend = True
else:
autoFriend = False
account = await database_sync_to_async(FaceitAccount.objects.filter(id=data['account_id'], owner__id=self.user.id).first)()
self.headers = {
"authorization": "Bearer " + account.bearer,
"faceit-referer": "new-frontend",
"referer": "https://api.faceit.com/proxy.html",
"origin":"https://api.faceit.com",
}
if account:
logger.info('Сканирование начилось')
self.autoFriend = autoFriend
self.maxFaceit = data['maxFaceit']
self.minFaceit = data['minFaceit']
self.maxInventory = data['maxInventory']
self.minInventory = data['minInventory']
self.region = data['region']
await self.send(text_data=json.dumps({
'code': "message_green",
'data': 'Скан успешно запущен'
}))
await self.startScan()
else:
await self.send(text_data=json.dumps({
"code": "message_red",
"data": "Аккаунт не найден"
}))
elif data["do"] == "finishScan":
self.stop = True
logger.info("Скан завершён")
await self.send(text_data=json.dumps({
'code': "message_green",
'data': 'Скан успешно завершён'
}))