email template
This commit is contained in:
parent
ebbb582e99
commit
2451045693
15 changed files with 447 additions and 156 deletions
|
|
@ -9,6 +9,11 @@ from app.models import Account
|
|||
from app.services.domain_provisioning import get_domain_by_name
|
||||
from app.services.email_templates import BRAND_NAME, build_employee_invitation_email
|
||||
from app.services.mail_sender import deliver_email
|
||||
from app.services.member_invitations import (
|
||||
INVITE_EXPIRY_HOURS,
|
||||
INVITE_FROM_LOCAL,
|
||||
create_member_invitation,
|
||||
)
|
||||
|
||||
|
||||
async def send_employee_invitation(
|
||||
|
|
@ -16,8 +21,6 @@ async def send_employee_invitation(
|
|||
*,
|
||||
member: Account,
|
||||
manager: Account,
|
||||
initial_password: str,
|
||||
force_password_change: bool,
|
||||
) -> None:
|
||||
if not member.invitation_email:
|
||||
raise ValueError("Invitation email is required.")
|
||||
|
|
@ -27,7 +30,8 @@ async def send_employee_invitation(
|
|||
if platform_domain is None:
|
||||
raise ValueError("Platform mail domain is not configured.")
|
||||
|
||||
login_url = f"https://{settings.app_public_host}/login"
|
||||
raw_token = await create_member_invitation(session, member)
|
||||
invite_url = f"https://{settings.app_public_host}/invite/{raw_token}"
|
||||
manager_name = f"{manager.first_name} {manager.last_name}".strip()
|
||||
company = member.company_domain or settings.platform_domain
|
||||
|
||||
|
|
@ -35,14 +39,12 @@ async def send_employee_invitation(
|
|||
member_first_name=member.first_name,
|
||||
member_email=member.email,
|
||||
manager_name=manager_name,
|
||||
manager_email=manager.email,
|
||||
company_domain=company,
|
||||
login_url=login_url,
|
||||
initial_password=initial_password,
|
||||
force_password_change=force_password_change,
|
||||
invite_url=invite_url,
|
||||
expires_hours=INVITE_EXPIRY_HOURS,
|
||||
)
|
||||
|
||||
sender = f"{BRAND_NAME} <noreply@{settings.platform_domain}>"
|
||||
sender = f"{BRAND_NAME} <{INVITE_FROM_LOCAL}@{settings.platform_domain}>"
|
||||
await deliver_email(
|
||||
sender=sender,
|
||||
recipients=[member.invitation_email],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue