mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-10 20:35:17 +02:00
- 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.
19 lines
629 B
Python
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")
|