from __future__ import annotations import logging from yuxi.channel.extensions.github.auth import verify_credentials logger = logging.getLogger(__name__) class GitHubStatusAdapter: async def probe(self, account: dict) -> bool: result = await verify_credentials(account) return result is not None def build_summary(self, snapshot: object) -> dict: webhook_path = getattr(snapshot, "webhook_path", None) or "/api/webhook/github" running = getattr(snapshot, "running", False) return { "channel": "github", "webhook_path": webhook_path, "webhook_registered": running, } def build_account_summary(self, account: dict, probe_result: dict | None = None) -> dict: summary: dict = { "account_id": account.get("account_id", ""), "configured": all([ account.get("app_id"), account.get("private_key"), account.get("installation_id"), account.get("webhook_secret"), ]), "dm_policy": account.get("dm_policy", "open"), "group_policy": account.get("group_policy", "open"), "repositories": account.get("repositories", []), } if probe_result: summary["rate_limit"] = probe_result.get("rate_limit", 5000) summary["rate_remaining"] = probe_result.get("rate_remaining", 5000) summary["online"] = True return summary