diff --git a/app/chat/websocket.py b/app/chat/websocket.py index b3de545..52ac8a7 100644 --- a/app/chat/websocket.py +++ b/app/chat/websocket.py @@ -18,7 +18,7 @@ from app.users.schemas import SUser class ConnectionManager: def __init__(self): - self.active_connections: dict[int, list[WebSocket]] = {} + self.active_connections: dict[int, list[WebSocket]] = defaultdict(list) self.message_methods = { "send": self.send, "delete": self.delete, @@ -29,8 +29,6 @@ class ConnectionManager: async def connect(self, chat_id: int, websocket: WebSocket, subprotocol: str | None = None): 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) async def disconnect(self, chat_id: int, websocket: WebSocket, code_and_reason: tuple[int, str] | None = None): diff --git a/app/tasks/email_templates.py b/app/tasks/email_templates.py index d763e81..9ee2443 100644 --- a/app/tasks/email_templates.py +++ b/app/tasks/email_templates.py @@ -16,9 +16,73 @@ def create_registration_confirmation_template( email.set_content( f""" -