db867dcbe5
Deploy to Staging / deploy (push) Has been cancelled
Conflict detector / main (push) Has been cancelled
Lint Backend / lint-backend (push) Has been cancelled
Playwright Tests / changes (push) Has been cancelled
Test Backend / test-backend (push) Has been cancelled
Test Docker Compose / test-docker-compose (push) Has been cancelled
Playwright Tests / test-playwright (1, 4) (push) Has been cancelled
Playwright Tests / test-playwright (2, 4) (push) Has been cancelled
Playwright Tests / test-playwright (3, 4) (push) Has been cancelled
Playwright Tests / test-playwright (4, 4) (push) Has been cancelled
Playwright Tests / merge-playwright-reports (push) Has been cancelled
Playwright Tests / alls-green-playwright (push) Has been cancelled
Issue Manager / issue-manager (push) Has been cancelled
32 lines
798 B
Python
32 lines
798 B
Python
from fastapi import APIRouter, Depends
|
|
from pydantic.networks import EmailStr
|
|
|
|
from app.api.deps import get_current_active_superuser
|
|
from app.models import Message
|
|
from app.utils import generate_test_email, send_email
|
|
|
|
router = APIRouter(prefix="/utils", tags=["utils"])
|
|
|
|
|
|
@router.post(
|
|
"/test-email/",
|
|
dependencies=[Depends(get_current_active_superuser)],
|
|
status_code=201,
|
|
)
|
|
def test_email(email_to: EmailStr) -> Message:
|
|
"""
|
|
测试邮件发送。
|
|
"""
|
|
email_data = generate_test_email(email_to=email_to)
|
|
send_email(
|
|
email_to=email_to,
|
|
subject=email_data.subject,
|
|
html_content=email_data.html_content,
|
|
)
|
|
return Message(message="测试邮件已发送")
|
|
|
|
|
|
@router.get("/health-check/")
|
|
async def health_check() -> bool:
|
|
return True
|