harden deploy reports and admin alerts
This commit is contained in:
@@ -36,8 +36,9 @@ from app.services.admin_notifications import (
|
||||
create_admin_notification,
|
||||
dismiss_admin_notification,
|
||||
mark_admin_notification_read,
|
||||
retry_admin_telegram_notifications,
|
||||
)
|
||||
from app.services.notifications import notify_user
|
||||
from app.services.notifications import notify_user, process_notification_queue
|
||||
|
||||
router = APIRouter(prefix="/admin", tags=["admin"])
|
||||
|
||||
@@ -456,6 +457,35 @@ async def read_all_admin_notifications(
|
||||
return {"updated": len(rows)}
|
||||
|
||||
|
||||
@router.post("/notifications/retry")
|
||||
async def retry_notifications(
|
||||
limit: int = 50,
|
||||
session: AsyncSession = Depends(get_session),
|
||||
current_user: User = Depends(get_current_telegram_user),
|
||||
) -> dict[str, Any]:
|
||||
require_admin_access(current_user, FULL_ADMIN_ROLES | {"support"})
|
||||
limit = min(max(limit, 1), 200)
|
||||
service_delivered = await process_notification_queue(session, limit=limit)
|
||||
admin_delivered = await retry_admin_telegram_notifications(session, limit=limit)
|
||||
await log_audit(
|
||||
session,
|
||||
actor=current_user,
|
||||
action="admin.notifications.retry",
|
||||
target_type="notifications",
|
||||
metadata={
|
||||
"limit": limit,
|
||||
"service_delivered": service_delivered,
|
||||
"admin_delivered": admin_delivered,
|
||||
},
|
||||
)
|
||||
await session.commit()
|
||||
return {
|
||||
"service_delivered": service_delivered,
|
||||
"admin_delivered": admin_delivered,
|
||||
"limit": limit,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/notifications/{notification_id}/dismiss")
|
||||
async def dismiss_notification(
|
||||
notification_id: int,
|
||||
|
||||
Reference in New Issue
Block a user