|
|
|
@ -472,7 +472,7 @@ class User(DBUser, BaseUser): |
|
|
|
|
sync_count = self.config["bridge.initial_chat_sync"] |
|
|
|
|
else: |
|
|
|
|
sync_count = None |
|
|
|
|
await self.connect_and_sync(sync_count) |
|
|
|
|
await self.connect_and_sync(sync_count, force_sync=False) |
|
|
|
|
else: |
|
|
|
|
await self.send_bridge_notice( |
|
|
|
|
f"Logged into KakaoTalk. To connect to chatroom updates, use the `sync` command." |
|
|
|
@ -488,11 +488,11 @@ class User(DBUser, BaseUser): |
|
|
|
|
} if self.ktid else {} |
|
|
|
|
|
|
|
|
|
@async_time(METRIC_CONNECT_AND_SYNC) |
|
|
|
|
async def connect_and_sync(self, sync_count: int | None) -> bool: |
|
|
|
|
async def connect_and_sync(self, sync_count: int | None, force_sync: bool) -> bool: |
|
|
|
|
# TODO Look for a way to sync all channels without (re-)logging in |
|
|
|
|
try: |
|
|
|
|
login_result = await self.client.connect() |
|
|
|
|
should_sync = await self.on_connect() |
|
|
|
|
should_sync = await self.on_connect(force_sync) |
|
|
|
|
if login_result and should_sync: |
|
|
|
|
await self._sync_channels(login_result, sync_count) |
|
|
|
|
return True |
|
|
|
@ -696,7 +696,7 @@ class User(DBUser, BaseUser): |
|
|
|
|
|
|
|
|
|
# region KakaoTalk event handling |
|
|
|
|
|
|
|
|
|
async def on_connect(self) -> bool: |
|
|
|
|
async def on_connect(self, force_sync: bool) -> bool: |
|
|
|
|
now = time.monotonic() |
|
|
|
|
disconnected_at = self._connection_time |
|
|
|
|
max_delay = self.config["bridge.resync_max_disconnected_time"] |
|
|
|
@ -704,7 +704,7 @@ class User(DBUser, BaseUser): |
|
|
|
|
self.is_connected = True |
|
|
|
|
self._track_metric(METRIC_CONNECTED, True) |
|
|
|
|
duration = int(now - disconnected_at) |
|
|
|
|
skip_sync = not first_connect and duration < max_delay |
|
|
|
|
skip_sync = not first_connect and not force_sync and duration < max_delay |
|
|
|
|
if skip_sync: |
|
|
|
|
self.log.debug(f"Disconnection lasted {duration} seconds, not re-syncing channels...") |
|
|
|
|
elif self.temp_disconnect_notices: |
|
|
|
|