30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
from uuid import UUID
|
|
|
|
import httpx
|
|
from asgiref.sync import async_to_sync
|
|
|
|
from task import celery
|
|
|
|
|
|
@celery.task(name='get_ip_info')
|
|
def get_ip_info(ip: str, session_id: UUID):
|
|
from auth.utils.ip_info import get_info
|
|
from auth.utils.mongo import use_auth_collection
|
|
result = get_info(ip)
|
|
async_to_sync(use_auth_collection('sessions').update_one({'_id': session_id},
|
|
{'$set': {'ip_info': result}}))
|
|
|
|
|
|
@celery.task(name='send_otp')
|
|
def send_otp(mobile: str, token: int):
|
|
response = httpx.get("http://www.0098sms.com/sendsmslink.aspx",
|
|
params={
|
|
"TO": mobile,
|
|
"FROM": 3000164545,
|
|
"TEXT": f'وای گرام. بفرمایید کد ورود یکبار مصرف: {token} ',
|
|
"USERNAME": "ysms1362",
|
|
"PASSWORD": "1234@Abcgh",
|
|
"DOMAIN": "0098"
|
|
})
|
|
return response.text
|