Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from aiohttp import ClientResponseError, ClientResponse
from motor.motor_asyncio import AsyncIOMotorClient
from pymongo.errors import ConfigurationError
from pymongo.uri_parser import parse_uri

from core.models import InvalidConfigError, getLogger

Expand Down Expand Up @@ -448,7 +449,8 @@ def __init__(self, bot):
raise RuntimeError

try:
db = AsyncIOMotorClient(mongo_uri).modmail_bot
database = parse_uri(mongo_uri).get('database') or 'modmail_bot'
db = AsyncIOMotorClient(mongo_uri)[database]
except ConfigurationError as e:
logger.critical(
"Your MongoDB CONNECTION_URI might be copied wrong, try re-copying from the source again. "
Expand Down Expand Up @@ -500,7 +502,8 @@ async def validate_database_connection(self, *, ssl_retry=True):
'run "Certificate.command" on MacOS, '
'and check certifi is up to date "pip3 install --upgrade certifi".'
)
self.db = AsyncIOMotorClient(mongo_uri, tlsAllowInvalidCertificates=True).modmail_bot
database = parse_uri(mongo_uri).get('database') or 'modmail_bot'
self.db = AsyncIOMotorClient(mongo_uri, tlsAllowInvalidCertificates=True)[database]
return await self.validate_database_connection(ssl_retry=False)
if "ServerSelectionTimeoutError" in message:
logger.critical(
Expand Down