feat: 알림 채널 B방식 다중 발송 적용
Some checks failed
Build and Push Images / build-backend (push) Has been cancelled

This commit is contained in:
qorgh529
2026-04-27 20:46:28 +09:00
parent 638f6773fb
commit 8774bbf128
2 changed files with 97 additions and 37 deletions

View File

@@ -490,15 +490,6 @@ def get_notify_config_from_db(conn) -> dict:
"alert_email_to": os.getenv("ALERT_EMAIL_TO", ""),
}
def refresh_notifier(conn):
"""활성화된 모든 채널 중 첫 번째 채널로 notifier 모듈 업데이트"""
import notifier
cfg = get_notify_config_from_db(conn)
notifier.DISCORD_WEBHOOK_URL = cfg["discord_webhook_url"]
notifier.GMAIL_USER = cfg["gmail_user"]
notifier.GMAIL_APP_PASSWORD = cfg["gmail_app_password"]
notifier.ALERT_EMAIL_TO = cfg["alert_email_to"]
@app.get("/api/admin/notify-channels")
def list_notify_channels(token=Depends(require_admin), conn=Depends(get_db)):
cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
@@ -516,7 +507,6 @@ def create_notify_channel(data: NotifyChannel, token=Depends(require_admin), con
""", (data.name, data.type, data.discord_webhook_url or "", data.gmail_user or "",
data.gmail_app_password or "", data.alert_email_to or "", data.enabled))
conn.commit()
refresh_notifier(conn)
return cur.fetchone()
@app.put("/api/admin/notify-channels/{channel_id}")
@@ -538,7 +528,6 @@ def update_notify_channel(channel_id: int, data: NotifyChannel, token=Depends(re
""", (data.name, data.type, data.discord_webhook_url or "", data.gmail_user or "",
data.alert_email_to or "", data.enabled, channel_id))
conn.commit()
refresh_notifier(conn)
return cur.fetchone()
@app.delete("/api/admin/notify-channels/{channel_id}")
@@ -546,7 +535,6 @@ def delete_notify_channel(channel_id: int, token=Depends(require_admin), conn=De
cur = conn.cursor()
cur.execute("DELETE FROM notify_channels WHERE id=%s", (channel_id,))
conn.commit()
refresh_notifier(conn)
return {"ok": True}
# ─── 하위호환: 기존 단일 설정 API ────────────────────────