SurfSense/surfsense_backend/app/gateway/__init__.py
DESKTOP-RTLN3BA\$punk ef7a20a5d0 feat(gateway): implement global messaging gateway toggle
- Added a global switch `GATEWAY_ENABLED` to control the activation of all messaging gateway channels (Telegram, WhatsApp, Slack, Discord).
- Updated relevant routes and workers to check the `GATEWAY_ENABLED` flag, returning 404 for HTTP routes when disabled.
- Enhanced documentation in the `.env.example` file to reflect the new configuration option.
2026-06-08 13:24:29 -07:00

19 lines
629 B
Python

"""Messaging gateway infrastructure for external chat channels."""
from __future__ import annotations
from fastapi import HTTPException, status
from app.config import config
def require_gateway_enabled() -> None:
"""FastAPI dependency that gates all gateway HTTP routes on the global flag.
Returns 404 (rather than 503) when ``GATEWAY_ENABLED`` is FALSE so that
disabling the gateway makes its webhook/OAuth/pairing surface indistinguishable
from a route that does not exist.
"""
if not config.GATEWAY_ENABLED:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Not Found")