Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /api /routes /v1 /notifications.py
| """ | |
| Notification Routes | |
| """ | |
| import logging | |
| from typing import Any | |
| from fastapi import APIRouter, Depends, HTTPException | |
| from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer | |
| router = APIRouter(prefix="/notifications", tags=["Notifications"]) | |
| security = HTTPBearer() | |
| logger = logging.getLogger(__name__) | |
| # Import verify_token from auth module | |
| try: | |
| from .auth import verify_token | |
| except ImportError: | |
| from api.auth_simple import verify_token as legacy_verify_token | |
| async def verify_token( | |
| credentials: HTTPAuthorizationCredentials = Depends(security), | |
| ): | |
| user = legacy_verify_token(credentials.credentials) | |
| if not user: | |
| raise HTTPException(status_code=401, detail="Invalid token") | |
| return user | |
| async def test_slack_notification(user: Any = Depends(verify_token)): | |
| """Test Slack notification""" | |
| import os | |
| webhook_url = os.getenv("SLACK_WEBHOOK_URL") | |
| if not webhook_url: | |
| return { | |
| "success": False, | |
| "message": "Slack webhook URL not configured", | |
| } | |
| # In production, actually send a test notification | |
| logger.info("Sending test Slack notification") | |
| return {"success": True, "message": "Test notification sent"} | |
| async def send_scan_complete_notification(scan_id: str, user: Any = Depends(verify_token)): | |
| """Send scan completion notification""" | |
| import os | |
| webhook_url = os.getenv("SLACK_WEBHOOK_URL") | |
| if not webhook_url: | |
| return { | |
| "success": False, | |
| "message": "Slack webhook URL not configured", | |
| } | |
| # In production, actually send the notification | |
| logger.info(f"Sending scan completion notification for scan {scan_id}") | |
| return { | |
| "success": True, | |
| "message": f"Notification sent for scan {scan_id}", | |
| "scan_id": scan_id, | |
| } | |
| async def test_email_notification(user: Any = Depends(verify_token)): | |
| """Test email notification""" | |
| logger.info("Sending test email notification") | |
| return {"success": True, "message": "Test email sent"} | |
Xet Storage Details
- Size:
- 2.17 kB
- Xet hash:
- 27fd6caeaa6f394d2881948331cfa60bc36a237a879f4e738e5945004b90db4e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.