fix: move hardcoded Discord webhook URL to env var #83

Merged
cal merged 4 commits from fix/remove-hardcoded-webhook into main 2026-04-08 02:28:21 +00:00
3 changed files with 13 additions and 1 deletions

3
.env
View File

@ -6,6 +6,9 @@ SBA_DB_USER_PASSWORD=your_production_password
# SBa API # SBa API
API_TOKEN=Tp3aO3jhYve5NJF1IqOmJTmk API_TOKEN=Tp3aO3jhYve5NJF1IqOmJTmk
# Integrations
DISCORD_WEBHOOK_URL=
# Universal # Universal
TZ=America/Chicago TZ=America/Chicago
LOG_LEVEL=INFO LOG_LEVEL=INFO

View File

@ -22,6 +22,9 @@ logger = logging.getLogger("discord_app")
# level=log_level # level=log_level
# ) # )
# Discord integration
DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL")
# Redis configuration # Redis configuration
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost") REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
REDIS_PORT = int(os.environ.get("REDIS_PORT", "6379")) REDIS_PORT = int(os.environ.get("REDIS_PORT", "6379"))
@ -516,7 +519,12 @@ def send_webhook_message(message: str) -> bool:
Returns: Returns:
bool: True if successful, False otherwise bool: True if successful, False otherwise
""" """
webhook_url = "https://discord.com/api/webhooks/1408811717424840876/7RXG_D5IqovA3Jwa9YOobUjVcVMuLc6cQyezABcWuXaHo5Fvz1en10M7J43o3OJ3bzGW" webhook_url = DISCORD_WEBHOOK_URL
if not webhook_url:
logger.warning(
"DISCORD_WEBHOOK_URL env var is not set — skipping webhook message"
)
return False
try: try:
payload = {"content": message} payload = {"content": message}

View File

@ -34,6 +34,7 @@ services:
- REDIS_HOST=sba_redis - REDIS_HOST=sba_redis
- REDIS_PORT=6379 - REDIS_PORT=6379
- REDIS_DB=0 - REDIS_DB=0
- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}
depends_on: depends_on:
- postgres - postgres
- redis - redis