Two authz behaviours were hard-coded on Platform.QQBOT/TELEGRAM/... in gateway/authz_mixin.py (_GROUP_CHAT_ENV, _ALLOWLIST_SUPPRESSES_PAIRING), so a plugin-registered platform could not get them and removing the bundled QQ adapter would silently drop QQ_GROUP_ALLOWED_USERS gating and change pairing. PlatformEntry gains group_allowed_chats_env and allowlist_suppresses_pairing; authz_mixin reads them through authz_field (live entry, else the bundled gateway_env.AUTHZ). Every bundled platform that was in the old tables declares them in its AUTHZ, so behaviour is unchanged.
24 lines
862 B
Python
24 lines
862 B
Python
"""SMS (Twilio) env -> gateway config bridge (``PlatformEntry.env_overrides``)."""
|
|
|
|
from gateway.config import GatewayConfig, Platform, PlatformConfig
|
|
from gateway.platform_env import EnvCred, getenv, home_step
|
|
|
|
|
|
def _api_key(config: GatewayConfig, sms_config: PlatformConfig) -> None:
|
|
sms_config.api_key = getenv("TWILIO_AUTH_TOKEN")
|
|
|
|
|
|
ENV_ENABLE_CREDENTIALS = ("TWILIO_ACCOUNT_SID",)
|
|
ENV_OVERRIDES = (
|
|
EnvCred(Platform.SMS, ("TWILIO_ACCOUNT_SID",), then=_api_key),
|
|
home_step(Platform.SMS, "SMS_HOME_CHANNEL"),
|
|
)
|
|
|
|
# Authorization env names (``PlatformEntry`` fields). Core reads them from this file when the
|
|
# live entry lacks them: a user plugin overriding this platform, safe mode, the plugin disabled.
|
|
AUTHZ = {
|
|
"allowed_users_env": "SMS_ALLOWED_USERS",
|
|
"allow_all_env": "SMS_ALLOW_ALL_USERS",
|
|
"allowlist_suppresses_pairing": True,
|
|
}
|