2019-03-11 13:36:42 +04:00
|
|
|
from fastapi import APIRouter, Depends
|
2020-01-19 22:40:50 +01:00
|
|
|
from pydantic.networks import EmailStr
|
2019-02-09 19:42:36 +04:00
|
|
|
|
2023-12-27 13:49:36 -05:00
|
|
|
from app.api.deps import get_current_active_superuser
|
|
|
|
|
from app.models import Message
|
2024-03-10 00:02:36 +01:00
|
|
|
from app.utils import generate_test_email, send_email
|
2019-02-09 19:42:36 +04:00
|
|
|
|
2024-12-02 13:04:03 +01:00
|
|
|
router = APIRouter(prefix="/utils", tags=["utils"])
|
2019-02-09 19:42:36 +04:00
|
|
|
|
|
|
|
|
|
2023-12-27 13:49:36 -05:00
|
|
|
@router.post(
|
|
|
|
|
"/test-email/",
|
|
|
|
|
dependencies=[Depends(get_current_active_superuser)],
|
|
|
|
|
status_code=201,
|
|
|
|
|
)
|
|
|
|
|
def test_email(email_to: EmailStr) -> Message:
|
2019-02-09 19:42:36 +04:00
|
|
|
"""
|
2019-04-19 09:45:23 +04:00
|
|
|
Test emails.
|
2019-02-09 19:42:36 +04:00
|
|
|
"""
|
2024-03-10 00:02:36 +01:00
|
|
|
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,
|
|
|
|
|
)
|
2023-12-27 13:49:36 -05:00
|
|
|
return Message(message="Test email sent")
|
2024-09-12 15:21:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@router.get("/health-check/")
|
|
|
|
|
async def health_check() -> bool:
|
|
|
|
|
return True
|