Skip to content

Commit

Permalink
Send STARTING and UNCONFIGURED states in bridge start()
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Aug 4, 2021
1 parent e5f46d3 commit 028a2d7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mautrix/bridge/bridge.py
Expand Up @@ -14,6 +14,7 @@
from mautrix.api import HTTPAPI

from ..util.program import Program
from ..util.bridge_state import BridgeState, BridgeStateEvent
from .config import BaseBridgeConfig
from .matrix import BaseMatrixHandler
from .portal import BasePortal
Expand Down Expand Up @@ -154,11 +155,20 @@ async def start(self) -> None:
self.log.debug("Starting appservice...")
await self.az.start(self.config["appservice.hostname"], self.config["appservice.port"])
await self.matrix.wait_for_connection()

status_endpoint = self.config["homeserver.status_endpoint"]
state = BridgeState(state_event=BridgeStateEvent.STARTING).fill()
await state.send(status_endpoint, self.az.as_token, self.log)

await self.matrix.init_encryption()
self.add_startup_actions(self.matrix.init_as_bot())
await super().start()
self.az.ready = True

if status_endpoint and await self.count_logged_in_users() > 0:
state = BridgeState(state_event=BridgeStateEvent.UNCONFIGURED).fill()
await state.send(status_endpoint, self.az.as_token, self.log)

async def stop(self) -> None:
await self.az.stop()
await super().stop()
Expand Down Expand Up @@ -200,3 +210,7 @@ async def get_double_puppet(self, user_id: UserID) -> 'BasePuppet':
@abstractmethod
def is_bridge_ghost(self, user_id: UserID) -> bool:
pass

@abstractmethod
async def count_logged_in_users(self) -> int:
return 0

0 comments on commit 028a2d7

Please sign in to comment.