from __future__ import annotations import logging import httpx logger = logging.getLogger(__name__) class IMessageStatusAdapter: async def probe(self, account: dict | None = None) -> bool: if not account: return False server_url = account.get("server_url", "") password = account.get("password", "") if not server_url or not password: return False try: async with httpx.AsyncClient(timeout=httpx.Timeout(5.0)) as client: resp = await client.get( f"{server_url}/api/v1/server/info", headers={"Password": password}, ) if resp.status_code == 200: data = resp.json() return data.get("data", {}).get("imessage_ready", False) return False except Exception as e: logger.warning("iMessage probe failed: %s", e) return False def build_summary(self, snapshot: object) -> dict: return { "channel": "imessage", "mode": "bluebubbles", } def resolve_account_state( self, account: dict, config: dict, configured: bool, enabled: bool ) -> str: if not configured: return "unconfigured" if not enabled: return "disabled" return "ok"