Spaces:
Running
Running
axeronis commited on
Commit ·
3b89d2d
1
Parent(s): 108aace
fix: restore escalation settings in API response & re-register correct bot webhook
Browse files
backend/app/api/notifications.py
CHANGED
|
@@ -40,10 +40,53 @@ class UnreadCountResponse(BaseModel):
|
|
| 40 |
class NotificationSettingsResponse(BaseModel):
|
| 41 |
telegram_enabled: bool
|
| 42 |
telegram_chat_id: Optional[str]
|
| 43 |
-
telegram_channel_id: Optional[str]
|
|
|
|
| 44 |
dashboard_enabled: bool
|
|
|
|
| 45 |
notify_hot_leads: bool
|
| 46 |
notify_qualification_complete: bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
class UpdateNotificationSettingsRequest(BaseModel):
|
|
|
|
| 40 |
class NotificationSettingsResponse(BaseModel):
|
| 41 |
telegram_enabled: bool
|
| 42 |
telegram_chat_id: Optional[str]
|
| 43 |
+
telegram_channel_id: Optional[str] = None # Added support for group ID
|
| 44 |
+
|
| 45 |
dashboard_enabled: bool
|
| 46 |
+
|
| 47 |
notify_hot_leads: bool
|
| 48 |
notify_qualification_complete: bool
|
| 49 |
+
|
| 50 |
+
# Escalation
|
| 51 |
+
notify_escalation_high: bool = True
|
| 52 |
+
notify_escalation_medium: bool = True
|
| 53 |
+
notify_escalation_low: bool = False
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
# ... endpoints ...
|
| 57 |
+
|
| 58 |
+
@router.get("/settings", response_model=NotificationSettingsResponse)
|
| 59 |
+
async def get_notification_settings(
|
| 60 |
+
session: AsyncSession = Depends(get_async_session),
|
| 61 |
+
current_user: User = Depends(get_current_user)
|
| 62 |
+
):
|
| 63 |
+
"""Get notification settings."""
|
| 64 |
+
stmt = select(NotificationSettings).where(
|
| 65 |
+
NotificationSettings.tenant_id == current_user.tenant_id
|
| 66 |
+
)
|
| 67 |
+
result = await session.execute(stmt)
|
| 68 |
+
settings = result.scalar_one_or_none()
|
| 69 |
+
|
| 70 |
+
if not settings:
|
| 71 |
+
# Create default settings
|
| 72 |
+
settings = NotificationSettings(tenant_id=current_user.tenant_id)
|
| 73 |
+
session.add(settings)
|
| 74 |
+
await session.commit()
|
| 75 |
+
await session.refresh(settings)
|
| 76 |
+
|
| 77 |
+
return NotificationSettingsResponse(
|
| 78 |
+
telegram_enabled=settings.telegram_enabled,
|
| 79 |
+
telegram_chat_id=settings.telegram_chat_id,
|
| 80 |
+
telegram_channel_id=settings.telegram_channel_id,
|
| 81 |
+
dashboard_enabled=settings.dashboard_enabled,
|
| 82 |
+
notify_hot_leads=settings.notify_hot_leads,
|
| 83 |
+
notify_qualification_complete=settings.notify_qualification_complete,
|
| 84 |
+
|
| 85 |
+
# Escalation
|
| 86 |
+
notify_escalation_high=settings.notify_escalation_high,
|
| 87 |
+
notify_escalation_medium=settings.notify_escalation_medium,
|
| 88 |
+
notify_escalation_low=settings.notify_escalation_low
|
| 89 |
+
)
|
| 90 |
|
| 91 |
|
| 92 |
class UpdateNotificationSettingsRequest(BaseModel):
|
backend/register_global_webhook.py
CHANGED
|
@@ -6,8 +6,8 @@ import os
|
|
| 6 |
|
| 7 |
load_dotenv() # Load from .env
|
| 8 |
|
| 9 |
-
# Token
|
| 10 |
-
TOKEN = "
|
| 11 |
APP_URL = "https://microfunnel-production.up.railway.app"
|
| 12 |
|
| 13 |
async def register_webhook():
|
|
|
|
| 6 |
|
| 7 |
load_dotenv() # Load from .env
|
| 8 |
|
| 9 |
+
# Token provided by user
|
| 10 |
+
TOKEN = "7734361434:AAGGKvlHN6BaND61F1Lr-0TQiBPsRWdmrRo"
|
| 11 |
APP_URL = "https://microfunnel-production.up.railway.app"
|
| 12 |
|
| 13 |
async def register_webhook():
|