Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2f0d98b
Write basic move out reminder mail
lukasjuhrich Nov 15, 2025
75051b4
TODOs
lukasjuhrich Nov 15, 2025
cdda755
Fix error path in uninitialized config access
lukasjuhrich Jun 24, 2025
62dfcad
Turn `pycroft.lib.mail` into package
lukasjuhrich Nov 15, 2025
7f22eaf
Turn `compose_mail` into method to be consistent with mime methods
lukasjuhrich Nov 22, 2025
c77e7e5
move `Mail` class into `pycroft.lib.mail.concepts`
lukasjuhrich Nov 22, 2025
1e92646
extract `pycroft.lib.mail.config`
lukasjuhrich Nov 22, 2025
4e1df62
Allow specifying custom template loader in MailTemplate constructor
lukasjuhrich Nov 22, 2025
6b1f8af
Move `MailTemplate` to `pycroft.lib.mail.concepts`
lukasjuhrich Nov 22, 2025
e919165
Extract `pycroft.lib.mail.submission`
lukasjuhrich Nov 22, 2025
fcb92d8
Removed unused imports
lukasjuhrich Nov 22, 2025
c0b21a0
Extract templates to `pycroft.lib.mail.templates`
lukasjuhrich Nov 22, 2025
e8b9324
Mark templates as final
lukasjuhrich Nov 22, 2025
a55ded5
Extract ssl context creation into separate method
lukasjuhrich Nov 23, 2025
25996dc
Promote `else` branch to outer scope
lukasjuhrich Nov 23, 2025
f99ba82
Use `t.Literal` for smtp ssl type config string
lukasjuhrich Nov 23, 2025
8b02e88
Extract smtp setup into own method
lukasjuhrich Nov 23, 2025
974f780
Inline variables only used once
lukasjuhrich Nov 23, 2025
9d01534
Move assertion to outer scope
lukasjuhrich Nov 23, 2025
902fa85
Fix typos in log message (host:host makes no sense)
lukasjuhrich Nov 23, 2025
410fd0c
black pycroft.lib.mail
lukasjuhrich Nov 23, 2025
0475515
Use match statement for improved type inference
lukasjuhrich Nov 23, 2025
27654ea
Strengthen isolated `smtp.close()` to context manager usage
lukasjuhrich Nov 23, 2025
7c6cdd0
Communicate parameter intent via assertions
lukasjuhrich Nov 23, 2025
9bb513a
Implement celery stubs for move_out reminder mail
lukasjuhrich Nov 23, 2025
c6565b7
Add helpful assertion to docstring
lukasjuhrich Nov 23, 2025
ea57b5f
Move stub functions to lib.user.mail
lukasjuhrich Nov 25, 2025
bb3f99e
Make celery task implementation testable and move to lib
lukasjuhrich Nov 25, 2025
875ad2d
Naively implement get_members_with_contract_end_at
lukasjuhrich Nov 25, 2025
ac27985
Add missing `_config_var` import in mail package
lukasjuhrich Nov 29, 2025
e7c43a8
Only show tenancies of users whose last eom is None
lukasjuhrich Nov 29, 2025
969c3ea
Add POC unit test for tenancy end reminder selection (one positive case)
lukasjuhrich Nov 29, 2025
03f553e
Move test to separate test file
lukasjuhrich Nov 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
317 changes: 0 additions & 317 deletions pycroft/lib/mail.py

This file was deleted.

45 changes: 45 additions & 0 deletions pycroft/lib/mail/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""
pycroft.lib.mail
~~~~~~~~~~~~~~~~
"""

from __future__ import annotations
import typing as t


from .concepts import Mail, MailTemplate
from .config import MailConfig, config, _config_var
from .submission import send_mails, RetryableException
from .templates import (
UserConfirmEmailTemplate,
UserResetPasswordTemplate,
UserMovedInTemplate,
UserCreatedTemplate,
MemberRequestPendingTemplate,
MemberRequestDeniedTemplate,
MemberRequestMergedTemplate,
TaskFailedTemplate,
MemberNegativeBalance,
)


def send_template_mails(
email_addresses: list[str], template: MailTemplate, **kwargs: t.Any
) -> None:
mails = []

for addr in email_addresses:
body_plain, body_html = template.render(**kwargs)

mail = Mail(
to_name="",
to_address=addr,
subject=template.subject,
body_plain=body_plain,
body_html=body_html,
)
mails.append(mail)

from pycroft.task import send_mails_async

send_mails_async.delay(mails)
Loading
Loading