setup_hidden_env.py 1.6 KB

123456789101112131415161718192021222324252627282930
  1. """Which platform env vars the setup surfaces hide.
  2. Hiding is a *presentation* decision only: the vars keep working through ``hermes config set``,
  3. ``.env`` and ``config.yaml``, and the gateway reads them exactly as before.
  4. """
  5. # Suffix match, so plugin adapters nobody enumerated (IRC, SimpleX, LINE, ntfy) get the same
  6. # treatment without a code change here.
  7. #
  8. # *_HOME_CHANNEL* the bot offers /sethome on the first chat
  9. # *_ALLOW_ALL_USERS defaults off; enabling it is a security decision
  10. # *_REPLY_TO_MODE / *_REPLY_MODE cosmetic threading preference (Mattermost spelling too)
  11. # *_REQUIRE_MENTION / *_AUTO_THREAD behavior toggles with sane defaults
  12. # *_FREE_RESPONSE_* / *_ALLOWED_CHANNELS per-channel tuning, done once the bot is in a server
  13. # *_PROXY only for networks that block the platform
  14. #
  15. # Allowlists (*_ALLOWED_USERS) deliberately stay visible: that IS the decision a new user has to
  16. # make, and the gateway denies everyone until it's set.
  17. SETUP_HIDDEN_ENV_SUFFIXES = (
  18. "_HOME_CHANNEL", "_HOME_CHANNEL_NAME", "_HOME_CHANNEL_THREAD_ID", "_HOME_ADDRESS", "_ALLOW_ALL_USERS",
  19. "_REPLY_TO_MODE", "_REPLY_MODE", "_REQUIRE_MENTION", "_AUTO_THREAD", "_FREE_RESPONSE_CHANNELS",
  20. "_FREE_RESPONSE_ROOMS", "_ALLOWED_CHANNELS", "_PROXY",
  21. )
  22. def is_setup_hidden_env(name: str) -> bool:
  23. """True when a var is self-configuring and shouldn't appear in setup forms. Callers must still
  24. keep any var a platform lists as *required* — hiding a required credential would make that
  25. platform unconfigurable from the UI."""
  26. return name.endswith(SETUP_HIDDEN_ENV_SUFFIXES)