requests-removed+fixes
This commit is contained in:
parent
fbc85f6c2d
commit
b8e6f7bb5a
|
@ -6,7 +6,7 @@ exclude: |
|
|||
)
|
||||
|
||||
default_language_version:
|
||||
python: python3.8
|
||||
python: python3.12
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
|
|
|
@ -4,6 +4,6 @@ WORKDIR /app
|
|||
EXPOSE 8080
|
||||
ADD nginx.conf.sigil ./
|
||||
COPY requirements.txt .
|
||||
RUN apt update && apt install -y git gcc
|
||||
RUN apt update && apt install -y build-essentials
|
||||
RUN pip install -r requirements.txt
|
||||
COPY . .
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
import requests
|
||||
from httpx import AsyncClient
|
||||
|
||||
from settings import MAILGUN_API_KEY, MAILGUN_DOMAIN
|
||||
|
||||
api_url = "https://api.mailgun.net/v3/%s/messages" % (MAILGUN_DOMAIN or 'discours.io')
|
||||
noreply = "discours.io <noreply@%s>" % (MAILGUN_DOMAIN or 'discours.io')
|
||||
lang_subject = {
|
||||
"ru": "Подтверждение почты",
|
||||
"en": "Confirm email"
|
||||
}
|
||||
api_url = "https://api.mailgun.net/v3/%s/messages" % (MAILGUN_DOMAIN or "discours.io")
|
||||
noreply = "discours.io <noreply@%s>" % (MAILGUN_DOMAIN or "discours.io")
|
||||
lang_subject = {"ru": "Подтверждение почты", "en": "Confirm email"}
|
||||
|
||||
|
||||
async def send_auth_email(user, token, lang="ru", template="email_confirmation"):
|
||||
try:
|
||||
to = "%s <%s>" % (user.name, user.email)
|
||||
if lang not in ['ru', 'en']:
|
||||
lang = 'ru'
|
||||
if lang not in ["ru", "en"]:
|
||||
lang = "ru"
|
||||
subject = lang_subject.get(lang, lang_subject["en"])
|
||||
template = template + "_" + lang
|
||||
payload = {
|
||||
|
@ -22,15 +19,17 @@ async def send_auth_email(user, token, lang="ru", template="email_confirmation")
|
|||
"to": to,
|
||||
"subject": subject,
|
||||
"template": template,
|
||||
"h:X-Mailgun-Variables": "{ \"token\": \"%s\" }" % token
|
||||
"h:X-Mailgun-Variables": '{ "token": "%s" }' % token,
|
||||
}
|
||||
print('[auth.email] payload: %r' % payload)
|
||||
print("[auth.email] payload: %r" % payload)
|
||||
# debug
|
||||
# print('http://localhost:3000/?modal=auth&mode=confirm-email&token=%s' % token)
|
||||
response = requests.post(
|
||||
api_url,
|
||||
auth=("api", MAILGUN_API_KEY),
|
||||
data=payload
|
||||
async with AsyncClient() as client:
|
||||
response = await client.post(api_url, headers=headers, data=gql)
|
||||
if response.status_code != 200:
|
||||
return False, None
|
||||
r = response.json()
|
||||
api_url, auth=("api", MAILGUN_API_KEY), data=payload
|
||||
)
|
||||
response.raise_for_status()
|
||||
except Exception as e:
|
||||
|
|
|
@ -11,7 +11,7 @@ from auth.tokenstorage import TokenStorage
|
|||
# from base.exceptions import InvalidPassword, InvalidToken
|
||||
from services.db import local_session
|
||||
from orm import User
|
||||
from validations.auth import AuthInput
|
||||
from auth.validators import AuthInput
|
||||
|
||||
|
||||
class Password:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime, timezone
|
||||
import jwt
|
||||
from services.exceptions import ExpiredToken, InvalidToken
|
||||
from validations.auth import TokenPayload, AuthInput
|
||||
from auth.validators import TokenPayload, AuthInput
|
||||
from settings import JWT_ALGORITHM, JWT_SECRET_KEY
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from auth.jwtcodec import JWTCodec
|
||||
from validations.auth import AuthInput
|
||||
from auth.validators import AuthInput
|
||||
from services.redis import redis
|
||||
from settings import SESSION_TOKEN_LIFE_SPAN, ONETIME_TOKEN_LIFE_SPAN
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
python-frontmatter~=1.0.0
|
||||
aredis
|
||||
aiohttp
|
||||
aredis~=1.1.8
|
||||
ariadne>=0.17.0
|
||||
PyYAML>=5.4
|
||||
pyjwt>=2.6.0
|
||||
|
@ -16,22 +15,18 @@ authlib>=1.1.0
|
|||
httpx>=0.23.0
|
||||
psycopg2-binary
|
||||
transliterate~=1.10.2
|
||||
requests
|
||||
bcrypt>=4.0.0
|
||||
websockets
|
||||
bson~=0.5.10
|
||||
flake8
|
||||
DateTime~=4.7
|
||||
asyncio~=3.4.3
|
||||
python-dateutil~=2.8.2
|
||||
beautifulsoup4~=4.11.1
|
||||
lxml
|
||||
sentry-sdk>=1.14.0
|
||||
# sse_starlette
|
||||
graphql-ws
|
||||
nltk~=3.8.1
|
||||
pymystem3~=0.2.0
|
||||
transformers~=4.28.1
|
||||
transformers
|
||||
boto3~=1.28.2
|
||||
botocore~=1.31.2
|
||||
python-multipart~=0.0.6
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
from typing import Optional, Text, List
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Message(BaseModel):
|
||||
id: int
|
||||
body: Text
|
||||
author: int
|
||||
chatId: Text
|
||||
createdAt: int
|
||||
updatedAt: Optional[int]
|
||||
replyTo: Optional[int]
|
||||
|
||||
|
||||
class Member(BaseModel):
|
||||
id: int
|
||||
name: Text
|
||||
pic: Optional[Text]
|
||||
# TODO: extend chat member model
|
||||
|
||||
|
||||
class Chat(BaseModel):
|
||||
createdAt: int
|
||||
createdBy: int
|
||||
users: List[int]
|
||||
updatedAt: Optional[int]
|
||||
title: Optional[Text]
|
||||
description: Optional[Text]
|
Loading…
Reference in New Issue
Block a user