Files
mtusi2026lab7/app/storage.py
T

23 lines
616 B
Python

import threading
from minio import Minio
from app.transport import s3_transport
from app.config import S3_ENDPOINT, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_BUCKET
users_lock = threading.Lock()
messages_lock = threading.Lock()
users_by_id: dict[str, dict] = {}
users_by_username: dict[str, dict] = {}
chats_by_id: dict[str, dict] = {}
messages_by_chat: dict[str, list[dict]] = {}
endpoint = S3_ENDPOINT.replace("http://", "").replace("https://", "")
minio_client = Minio(
endpoint,
access_key=S3_ACCESS_KEY_ID,
secret_key=S3_SECRET_ACCESS_KEY,
**s3_transport(S3_ENDPOINT),
)
BUCKET = S3_BUCKET