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