Fix(API): Added email template
- Fix the missing logging library
This commit is contained in:
parent
8ef0ccf32e
commit
ad5596c61c
@ -27,7 +27,7 @@ async def send_email(
|
||||
response = await client.post(
|
||||
"https://api.postmarkapp.com/email",
|
||||
json={
|
||||
"From": "Tozo <help@tozo.dev>",
|
||||
"From": "Todo <todo@minhtrannhat.com>",
|
||||
"To": to,
|
||||
"Subject": subject,
|
||||
"Tag": template,
|
||||
|
@ -23,6 +23,9 @@ from quart_schema import QuartSchema, RequestSchemaValidationError
|
||||
# PostgreSQL database driver
|
||||
from quart_db import QuartDB
|
||||
|
||||
# logging
|
||||
import logging
|
||||
|
||||
|
||||
app: Quart = Quart(__name__)
|
||||
|
||||
@ -34,7 +37,7 @@ auth_manager: AuthManager = AuthManager(app)
|
||||
quart_db = QuartDB(app)
|
||||
rate_limiter: RateLimiter = RateLimiter(app)
|
||||
schema = QuartSchema(app, convert_casing=True)
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
app.register_blueprint(control_blueprint)
|
||||
|
||||
|
51
backend/src/backend/templates/email.html
Normal file
51
backend/src/backend/templates/email.html
Normal file
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tozo - email</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
</head>
|
||||
|
||||
<body
|
||||
style="
|
||||
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
|
||||
font-size: 14px;
|
||||
font-style: normal;
|
||||
margin: 0;
|
||||
"
|
||||
>
|
||||
<table
|
||||
width="100%"
|
||||
height="100%"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
border="0"
|
||||
>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<table
|
||||
height="100%"
|
||||
cellpadding="20"
|
||||
cellspacing="0"
|
||||
border="0"
|
||||
style="max-width: 540px"
|
||||
>
|
||||
<tr>
|
||||
<td align="left" width="540">
|
||||
{% block welcome %} Hello, {% endblock %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" width="540">
|
||||
{% block content %} Example content {% endblock %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" width="540">The Tozo team</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -6,5 +6,5 @@ from backend.lib.email import send_email
|
||||
|
||||
async def test_send_email(app: Quart, caplog: LogCaptureFixture) -> None:
|
||||
async with app.app_context():
|
||||
await send_email("member@tozo.dev", "Welcome", "email.html", {})
|
||||
assert "Sending email.html to member@tozo.dev" in caplog.text
|
||||
await send_email("member@minhtrannhat.com", "Welcome", "email.html", {})
|
||||
assert "Sending email.html to member@minhtrannhat.com" in caplog.text
|
Loading…
x
Reference in New Issue
Block a user