gateway_env.py 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. """BlueBubbles (iMessage) env -> gateway config bridge (``PlatformEntry.env_overrides``)."""
  2. from gateway.config import Platform
  3. from gateway.platform_env import EnvCred, home_step, int_or, mention_patterns, strip_slash, truthy_token
  4. from utils import is_truthy_value
  5. ENV_ENABLE_CREDENTIALS = ("BLUEBUBBLES_SERVER_URL", "BLUEBUBBLES_PASSWORD")
  6. # ``require_mention`` is always written: an unset env reads as "" -> False.
  7. ENV_OVERRIDES = (
  8. EnvCred(
  9. Platform.BLUEBUBBLES, ("BLUEBUBBLES_SERVER_URL", "BLUEBUBBLES_PASSWORD"),
  10. fixed=(
  11. ("server_url", "BLUEBUBBLES_SERVER_URL", "", strip_slash), ("password", "BLUEBUBBLES_PASSWORD"),
  12. ("webhook_host", "BLUEBUBBLES_WEBHOOK_HOST", "127.0.0.1"),
  13. ("webhook_port", "BLUEBUBBLES_WEBHOOK_PORT", "", int_or(8645)),
  14. ("webhook_path", "BLUEBUBBLES_WEBHOOK_PATH", "/bluebubbles-webhook"),
  15. ("send_read_receipts", "BLUEBUBBLES_SEND_READ_RECEIPTS", "true", is_truthy_value),
  16. ("require_mention", "BLUEBUBBLES_REQUIRE_MENTION", "", truthy_token),
  17. ),
  18. optional=(("mention_patterns", "BLUEBUBBLES_MENTION_PATTERNS", mention_patterns),),
  19. ),
  20. home_step(Platform.BLUEBUBBLES, "BLUEBUBBLES_HOME_CHANNEL"),
  21. )
  22. # Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the
  23. # live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.
  24. AUTHZ = {
  25. "allowed_users_env": "BLUEBUBBLES_ALLOWED_USERS",
  26. "allow_all_env": "BLUEBUBBLES_ALLOW_ALL_USERS",
  27. "allowlist_suppresses_pairing": True,
  28. }