fix: move hardcoded Discord webhook URL to env var #83
@ -503,6 +503,9 @@ def update_season_pitching_stats(player_ids, season, db_connection):
|
||||
raise
|
||||
|
||||
|
||||
DISCORD_WEBHOOK_URL = os.environ.get("DISCORD_WEBHOOK_URL")
|
||||
|
|
||||
|
||||
|
||||
def send_webhook_message(message: str) -> bool:
|
||||
"""
|
||||
Send a message to Discord via webhook.
|
||||
@ -513,7 +516,12 @@ def send_webhook_message(message: str) -> bool:
|
||||
Returns:
|
||||
bool: True if successful, False otherwise
|
||||
"""
|
||||
webhook_url = "https://discord.com/api/webhooks/1408811717424840876/7RXG_D5IqovA3Jwa9YOobUjVcVMuLc6cQyezABcWuXaHo5Fvz1en10M7J43o3OJ3bzGW"
|
||||
webhook_url = DISCORD_WEBHOOK_URL
|
||||
|
cal
commented
`DISCORD_WEBHOOK_URL` is not included in the `api` service `environment` block in `docker-compose.yml`. Without `- DISCORD_WEBHOOK_URL=${DISCORD_WEBHOOK_URL}` in that file, this `os.environ.get` will always return `None` in every deployed environment (dev and prod) and the webhook will silently do nothing.
|
||||
if not webhook_url:
|
||||
logger.warning(
|
||||
"DISCORD_WEBHOOK_URL env var is not set — skipping webhook message"
|
||||
)
|
||||
return False
|
||||
|
||||
try:
|
||||
payload = {"content": message}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user
All other env-var module-level constants (
REDIS_HOST,REDIS_PORT,REDIS_DB,CACHE_ENABLED) are grouped together near the top of the file around lines 26–29. Declaring this one mid-file is inconsistent with that pattern. Consider moving it there.