fixed newsletter data
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 21s
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 21s
This commit is contained in:
parent
34ed6f3144
commit
0d069deb34
2 changed files with 13 additions and 7 deletions
|
|
@ -7,16 +7,16 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<h1>Neuer Artikel:</h1>
|
<h1>Hey {{data.user.name}}, es gibt einen neuen Artikel:</h1>
|
||||||
<h3>{{data.title}}</h3>
|
<h3>{{data.article.title}}</h3>
|
||||||
<h4>{{data.subtitle}}</h4>
|
<h4>{{data.article.subtitle}}</h4>
|
||||||
<p>{{data.description}}</p>
|
<p>{{data.article.description}}</p>
|
||||||
|
|
||||||
<a href={{data.link}}>
|
<a href={{data.article.link}}>
|
||||||
<button>Zum Artikel</button>
|
<button>Zum Artikel</button>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="https://blauwasser-mausis.de/blog/bootsuche-england">
|
<a href="https://blauwasser-mausis.de/">
|
||||||
<span>Abbestellen</span>
|
<span>Abbestellen</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,16 @@ def approve_newsletter(secret: str = Form(), session: Session = Depends(get_sess
|
||||||
if title is not None:
|
if title is not None:
|
||||||
article = find_article_by_title(title)
|
article = find_article_by_title(title)
|
||||||
if article is not None:
|
if article is not None:
|
||||||
|
article_data = {
|
||||||
|
title: article["title"],
|
||||||
|
title: article["subtitle"],
|
||||||
|
title: article["summary"],
|
||||||
|
title: article["link"],
|
||||||
|
}
|
||||||
subscribed_users = session.exec(select(User).where(User.subscription == True))
|
subscribed_users = session.exec(select(User).where(User.subscription == True))
|
||||||
mails: list[BatchEmailRequest] = []
|
mails: list[BatchEmailRequest] = []
|
||||||
for user in subscribed_users:
|
for user in subscribed_users:
|
||||||
html = create_html_from_template("newsletter", user)
|
html = create_html_from_template("newsletter", {user: user, article: article_data })
|
||||||
mail = BatchEmailRequest(to=[Address(email=user.email,name=user.name)],html=html)
|
mail = BatchEmailRequest(to=[Address(email=user.email,name=user.name)],html=html)
|
||||||
mails.append(mail)
|
mails.append(mail)
|
||||||
send_batch_mail(mails)
|
send_batch_mail(mails)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue