Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
raidensakura committed May 9, 2023
1 parent 3d5bd91 commit 7fb3f7a
Showing 1 changed file with 5 additions and 2 deletions.
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 @@ -445,7 +446,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 @@ -497,7 +499,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

0 comments on commit 7fb3f7a

Please sign in to comment.