Stop creating connections for unauthenticated users at startup

This commit is contained in:
Tulir Asokan
2018-06-25 21:30:54 +03:00
parent 0f8a2e7c51
commit 371c6813de
4 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -95,7 +95,7 @@ class AbstractUser:
async def has_full_access(self, allow_bot=False):
return self.whitelisted and (not self.is_bot or allow_bot) and await self.is_logged_in()
async def start(self):
async def start(self, delete_unless_authenticated=False):
if not self.client:
self._init_client()
await self.client.connect()
@@ -113,7 +113,7 @@ class AbstractUser:
self.session_container.Session.query.filter(
self.session_container.Session.session_id == self.mxid).count() > 0)
if not self.connected and should_connect:
await self.start()
await self.start(delete_unless_authenticated=not even_if_no_session)
return self
def stop(self):