feat: Check Supabase alerts_enabled before sending telegram

This commit is contained in:
haneulai 2026-04-14 16:40:59 +09:00
parent 19103b3226
commit c736b2982f

View File

@ -81,6 +81,19 @@ class AlertManager:
if not site_id:
return
# 1.5. DB에서 알림 활성화 상태 확인
try:
from database import get_supabase_client
client = get_supabase_client()
if client:
company_id = plant_info.get('company_id', 1)
resp = client.table("plants").select("alerts_enabled").eq("id", site_id).eq("company_id", company_id).execute()
if resp.data and resp.data[0].get('alerts_enabled') is False:
print(f" 🔇 [Alert] {plant_name}: 알림이 비활성화되어 있습니다.")
return
except Exception as e:
print(f" ⚠️ 알림 설정 확인 중 오류: {e}")
# 2. 현재 DB 상태 확인
current_status = 'NORMAL'
with sqlite3.connect(self.db_path) as conn: