-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mail endpoint for sending test emails
Introduced a new API endpoint to send test emails to curators. A new `TestMail` model was added to handle the email payload. Updated the API router to include routes for the mailing functionality.
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from fastapi import APIRouter, Body, Depends, HTTPException, status, Response, Request, BackgroundTasks | ||
from fastapi.responses import JSONResponse | ||
from fastapi.encoders import jsonable_encoder | ||
|
||
from app.api.middlewares.http_basic_auth import * | ||
from app.api.models.setup.project import TestMail | ||
from app.tasks.email.send_mail import send_curator_mail | ||
|
||
router = APIRouter() | ||
|
||
@router.post("/send_test_curator_mail", summary="Send test mail", status_code=status.HTTP_201_CREATED, | ||
response_class=Response, dependencies=[Depends(basic_auth)], | ||
description="Send Curator Test Mail") | ||
async def send_test_mail(request: Request, payload: TestMail, background_tasks: BackgroundTasks): | ||
|
||
username = payload.username | ||
project_name = payload.projectname | ||
submission_url = payload.submission_url | ||
|
||
curator_mail = os.environ.get("CURATOR_MAIL", None) | ||
curator_mail = curator_mail.split(',') | ||
|
||
|
||
background_tasks.add_task(send_curator_mail, curator_mail, username, project_name, submission_url) | ||
return Response(status_code=status.HTTP_201_CREATED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel | ||
from typing import Optional | ||
from typing import Optional, List | ||
|
||
|
||
class Project(BaseModel): | ||
project_id: int | ||
overwrite: Optional[bool] = False | ||
|
||
class Projects(BaseModel): | ||
overwrite: Optional[bool] = False | ||
|
||
class TestMail(BaseModel): | ||
receiver: List[str] | ||
username: str | ||
projectname: str | ||
submission_url: str |