26 lines
673 B
Python
26 lines
673 B
Python
from fastapi import BackgroundTasks
|
|
from pydantic import BaseModel
|
|
from background_jobs.send_email import send_email
|
|
from emails.emails import ContactFormEmail
|
|
|
|
|
|
class ContactInput(BaseModel):
|
|
email_from: str
|
|
content: str
|
|
|
|
|
|
class ContactEndpoint():
|
|
async def on_post(self, input: ContactInput, backgorund_tasks: BackgroundTasks):
|
|
backgorund_tasks.add_task(send_email, ContactFormEmail(
|
|
email_from=input.email_from,
|
|
content=input.content
|
|
))
|
|
|
|
return {
|
|
"status": "success",
|
|
"email": {
|
|
"from": input.email_from,
|
|
"content": input.content
|
|
}
|
|
}
|