Compare commits
No commits in common. "89e2b480a2b4c7355e75c8f2bd5571952156cabe" and "6f666984c8f73852414d2d995c4dff1ef73529c6" have entirely different histories.
89e2b480a2
...
6f666984c8
5 changed files with 6 additions and 12 deletions
2
backend/.gitignore
vendored
2
backend/.gitignore
vendored
|
|
@ -1,4 +1,4 @@
|
|||
.venv/lib/**
|
||||
.venv/lib64/*
|
||||
*.db
|
||||
dev.db
|
||||
*.pyc
|
||||
BIN
backend/dev.db
Normal file
BIN
backend/dev.db
Normal file
Binary file not shown.
|
|
@ -1,4 +1,3 @@
|
|||
from pathlib import Path
|
||||
from backend.config import MAILTRAP_API_TOKEN
|
||||
from mailtrap import BatchEmailRequest
|
||||
from mailtrap import BatchSendEmailParams
|
||||
|
|
@ -7,8 +6,6 @@ from mailtrap import Mail
|
|||
import mailtrap as mt
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
APP_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
class ArticleData():
|
||||
def __init__(self, title, subtitle, description, link):
|
||||
self.title=title
|
||||
|
|
@ -21,7 +18,6 @@ class ArticleData():
|
|||
description: str
|
||||
link: str
|
||||
|
||||
|
||||
class AdminApprovalData(ArticleData):
|
||||
def __init__(self,title, subtitle, description, link, secret):
|
||||
ArticleData.__init__(self, title, subtitle, description, link)
|
||||
|
|
@ -29,13 +25,11 @@ class AdminApprovalData(ArticleData):
|
|||
|
||||
secret: str
|
||||
|
||||
|
||||
def create_html_from_template(template_name: str, data):
|
||||
env = Environment(loader = FileSystemLoader(f'{APP_ROOT}/internal/jinja_templates'))
|
||||
env = Environment(loader = FileSystemLoader('src/backend/internal/jinja_templates'))
|
||||
template = env.get_template(f"{template_name}.jinja")
|
||||
return template.render(data=data)
|
||||
|
||||
|
||||
def send_newsletter_admin_approval(data: ArticleData ):
|
||||
html = create_html_from_template("approval", data)
|
||||
|
||||
|
|
@ -47,7 +41,6 @@ def send_newsletter_admin_approval(data: ArticleData ):
|
|||
)
|
||||
send_mail(mail)
|
||||
|
||||
|
||||
def send_mail(mail: Mail):
|
||||
if ENVIRONMENT == "local":
|
||||
print(f"Mail sent: {mail.subject}")
|
||||
|
|
@ -56,7 +49,6 @@ def send_mail(mail: Mail):
|
|||
client = mt.MailtrapClient(token=MAILTRAP_API_TOKEN)
|
||||
client.send(mail)
|
||||
|
||||
|
||||
def send_batch_mail(mails: list[BatchEmailRequest]):
|
||||
if ENVIRONMENT == "local":
|
||||
for mail in mails:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ from fastapi import FastAPI
|
|||
from fastapi_crons import Crons
|
||||
from backend.internal.rss_reader import check_blog_rss_and_send_admin_mail
|
||||
|
||||
|
||||
# TODO: TLS
|
||||
# TODO: Deploy
|
||||
|
||||
app = FastAPI()
|
||||
crons = Crons(app)
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ def register_user(new_user: NewUser, session: Session = Depends(get_session)):
|
|||
except IntegrityError as e:
|
||||
session.rollback()
|
||||
raise HTTPException(HTTP_400_BAD_REQUEST)
|
||||
except Exception:
|
||||
session.rollback()
|
||||
|
||||
|
||||
@router.post(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue