Тест long polling
This commit is contained in:
parent
853a0fc9c0
commit
7293399353
2 changed files with 68 additions and 6 deletions
|
@ -18,7 +18,7 @@ from app.users.schemas import SUser
|
||||||
|
|
||||||
class ConnectionManager:
|
class ConnectionManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.active_connections: dict[int, list[WebSocket]] = {}
|
self.active_connections: dict[int, list[WebSocket]] = defaultdict(list)
|
||||||
self.message_methods = {
|
self.message_methods = {
|
||||||
"send": self.send,
|
"send": self.send,
|
||||||
"delete": self.delete,
|
"delete": self.delete,
|
||||||
|
@ -29,8 +29,6 @@ class ConnectionManager:
|
||||||
|
|
||||||
async def connect(self, chat_id: int, websocket: WebSocket, subprotocol: str | None = None):
|
async def connect(self, chat_id: int, websocket: WebSocket, subprotocol: str | None = None):
|
||||||
await websocket.accept(subprotocol=subprotocol)
|
await websocket.accept(subprotocol=subprotocol)
|
||||||
if chat_id not in self.active_connections:
|
|
||||||
self.active_connections[chat_id] = []
|
|
||||||
self.active_connections[chat_id].append(websocket)
|
self.active_connections[chat_id].append(websocket)
|
||||||
|
|
||||||
async def disconnect(self, chat_id: int, websocket: WebSocket, code_and_reason: tuple[int, str] | None = None):
|
async def disconnect(self, chat_id: int, websocket: WebSocket, code_and_reason: tuple[int, str] | None = None):
|
||||||
|
|
|
@ -16,9 +16,73 @@ def create_registration_confirmation_template(
|
||||||
|
|
||||||
email.set_content(
|
email.set_content(
|
||||||
f"""
|
f"""
|
||||||
<h1 style="background-color: red;">{username}, лови аптечку</h1>
|
<!DOCTYPE html>
|
||||||
{confirmation_link}
|
<html lang="en">
|
||||||
{confirmation_code}
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<title>Pegr</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<body style="
|
||||||
|
width:99%;
|
||||||
|
height:99%;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction:column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
background-color:#101010;
|
||||||
|
|
||||||
|
font-family: 'Comfortaa';
|
||||||
|
src: url('./fonts/Comfortaa-VariableFont_wght.ttf') format('truetype');
|
||||||
|
font-weight: 1 1000; /* Объявляем диапазон веса шрифта */
|
||||||
|
font-style: normal;
|
||||||
|
font-stretch: normal;">
|
||||||
|
|
||||||
|
<div style="display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content:space-around;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
height:500px;
|
||||||
|
aspect-ratio: 1 / 1.44;
|
||||||
|
|
||||||
|
border: 1px solid transparent;
|
||||||
|
background:
|
||||||
|
linear-gradient(#101010, #101010) padding-box,
|
||||||
|
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||||||
|
border-radius: 15px;
|
||||||
|
">
|
||||||
|
|
||||||
|
<h1 style=" color:white;">Код подтверждения для {username}</h1>
|
||||||
|
<div style="border: 1px solid transparent;
|
||||||
|
background:
|
||||||
|
linear-gradient(#101010, #101010) padding-box,
|
||||||
|
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||||||
|
border-radius: 15px;">
|
||||||
|
|
||||||
|
<h2 style="color:white;
|
||||||
|
padding:0 5px 0 5px;">Код {confirmation_code}</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 style="color:white;">или</h1>
|
||||||
|
|
||||||
|
<a href="{confirmation_link}" style="border: 1px solid transparent;
|
||||||
|
background:
|
||||||
|
linear-gradient(#101010, #101010) padding-box,
|
||||||
|
linear-gradient(to bottom, #3C53FF, #7734AA) border-box;
|
||||||
|
border-radius: 15px;
|
||||||
|
text-decoration: none;">
|
||||||
|
|
||||||
|
<h2 style="color: white;
|
||||||
|
padding:0 5px 0 5px;">перейдите по ссылке</h2>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
""",
|
""",
|
||||||
subtype="html",
|
subtype="html",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue