Spaces:
Running
Running
axeronis commited on
Commit ·
ace167a
1
Parent(s): f496bdd
debug: add extensive logging to notify_hot_lead
Browse files143 unmodified lines14414514614714814915015115215315415515615715813 unmodified lines172173174175176177178143 unmodified linesasync def notify_hot_lead(self, session: Any, tenant: Tenant, lead, trigger_reason: str = None):"""Send alert when lead becomes HOT (heat >= 70)."""settings = await self._get_settings(session, tenant.id)# Check explicit disabled flag ONLY if settings existif settings and settings.telegram_enabled is False:returntg_chat_id = await self._get_target_chat_id(session, tenant.id, settings)if not tg_chat_id:returnlead_name = lead.name if lead else 'Неизвестно'heat_score = getattr(lead, 'heat_score', 0) or 013 unmodified linesf"───────────────\n"f"⚡ Причина: {trigger_reason or 'Набрал высокий скор'}")await self._send_telegram(tenant.telegram_bot_token, tg_chat_id, message)async def notify_qualification_complete(self, session: Any, lead, tenant: Tenant, qualification_data: Dict = None):"""Send alert when lead is qualified."""143 unmodified lines14414514614714814915015115215315415515615715815916016116216316416513 unmodified lines179180181182183184185186187143 unmodified linesasync def notify_hot_lead(self, session: Any, tenant: Tenant, lead, trigger_reason: str = None):"""Send alert when lead becomes HOT (heat >= 70)."""logger.info(f"🔥 [HOT_LEAD] notify_hot_lead called for lead={lead.id}, tenant={tenant.id}")settings = await self._get_settings(session, tenant.id)logger.info(f"🔥 [HOT_LEAD] Settings: {settings}, telegram_enabled={getattr(settings, 'telegram_enabled', None) if settings else None}")# Check explicit disabled flag ONLY if settings existif settings and settings.telegram_enabled is False:logger.info(f"🔥 [HOT_LEAD] Telegram disabled in settings, skipping")returntg_chat_id = await self._get_target_chat_id(session, tenant.id, settings)logger.info(f"🔥 [HOT_LEAD] Target chat_id: {tg_chat_id}")if not tg_chat_id:logger.warning(f"🔥 [HOT_LEAD] No chat_id found - notification NOT sent!")returnlead_name = lead.name if lead else 'Неизвестно'heat_score = getattr(lead, 'heat_score', 0) or 013 unmodified linesf"───────────────\n"f"⚡ Причина: {trigger_reason or 'Набрал высокий скор'}")logger.info(f"🔥 [HOT_LEAD] Sending notification to {tg_chat_id}...")await self._send_telegram(tenant.telegram_bot_token, tg_chat_id, message)logger.info(f"🔥 [HOT_LEAD] Notification sent successfully!")async def notify_qualification_complete(self, session: Any, lead, tenant: Tenant, qualification_data: Dict = None):"""Send alert when lead is qualified."""
backend/app/services/notification.py+10-1