Implement get_bridge_states
This commit is contained in:
@@ -232,7 +232,7 @@ class User(AbstractUser, BaseUser):
|
|||||||
@property
|
@property
|
||||||
def _is_connected(self) -> bool:
|
def _is_connected(self) -> bool:
|
||||||
return bool(self.client and self.client._sender
|
return bool(self.client and self.client._sender
|
||||||
and self.client._sender._transport_connected)
|
and self.client._sender._transport_connected())
|
||||||
|
|
||||||
async def _track_connection(self) -> None:
|
async def _track_connection(self) -> None:
|
||||||
self.log.debug("Starting loop to track connection state")
|
self.log.debug("Starting loop to track connection state")
|
||||||
@@ -252,6 +252,18 @@ class User(AbstractUser, BaseUser):
|
|||||||
state.remote_id = str(self.tgid)
|
state.remote_id = str(self.tgid)
|
||||||
state.remote_name = self.human_tg_id
|
state.remote_name = self.human_tg_id
|
||||||
|
|
||||||
|
async def get_bridge_states(self) -> List[BridgeState]:
|
||||||
|
if not self.tgid:
|
||||||
|
return []
|
||||||
|
if self._is_connected and await self.is_logged_in():
|
||||||
|
state_event = (BridgeStateEvent.BACKFILLING if self._is_backfilling
|
||||||
|
else BridgeStateEvent.CONNECTED)
|
||||||
|
ttl = 3600
|
||||||
|
else:
|
||||||
|
state_event = BridgeStateEvent.UNKNOWN_ERROR
|
||||||
|
ttl = 240
|
||||||
|
return [BridgeState(state_event=state_event, ttl=ttl)]
|
||||||
|
|
||||||
async def get_puppet(self) -> Optional['pu.Puppet']:
|
async def get_puppet(self) -> Optional['pu.Puppet']:
|
||||||
if not self.tgid:
|
if not self.tgid:
|
||||||
return None
|
return None
|
||||||
|
|||||||
+1
-1
@@ -5,6 +5,6 @@ python-magic>=0.4,<0.5
|
|||||||
commonmark>=0.8,<0.10
|
commonmark>=0.8,<0.10
|
||||||
aiohttp>=3,<4
|
aiohttp>=3,<4
|
||||||
yarl>=1,<2
|
yarl>=1,<2
|
||||||
mautrix>=0.10.4,<0.11
|
mautrix>=0.10.5,<0.11
|
||||||
telethon>=1.22,<1.24
|
telethon>=1.22,<1.24
|
||||||
telethon-session-sqlalchemy>=0.2.14,<0.3
|
telethon-session-sqlalchemy>=0.2.14,<0.3
|
||||||
|
|||||||
Reference in New Issue
Block a user