Add notifications API endpoint

This commit is contained in:
thePR0M3TH3AN
2025-07-14 11:43:09 -04:00
parent 306480896e
commit d87d9ed59f
3 changed files with 45 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import os
import tempfile
from pathlib import Path
import secrets
import queue
from typing import Any, List, Optional
from fastapi import FastAPI, Header, HTTPException, Request, Response
@@ -379,6 +380,21 @@ def get_profile_stats(authorization: str | None = Header(None)) -> dict:
return _pm.get_profile_stats()
@app.get("/api/v1/notifications")
def get_notifications(authorization: str | None = Header(None)) -> List[dict]:
"""Return and clear queued notifications."""
_check_token(authorization)
assert _pm is not None
notes = []
while True:
try:
note = _pm.notifications.get_nowait()
except queue.Empty:
break
notes.append({"level": note.level, "message": note.message})
return notes
@app.get("/api/v1/parent-seed")
def get_parent_seed(
authorization: str | None = Header(None), file: str | None = None