feat(organizations): email inviter when membership invite is accepted
When a user accepts an org invite, send a notification email to the person who sent the invite with membership details (member name, email, org name, role) and an optional View Organization button. Added build_invite_accepted_html() template to email_templates.py, wired it into the accept_invite() handler, and added a test case.
This commit is contained in:
@@ -243,6 +243,30 @@ def accept_invite(token):
|
||||
|
||||
invite.accept()
|
||||
|
||||
if invite.invited_by and invite.invited_by.email:
|
||||
from gatehouse_app.services.email_templates import build_invite_accepted_html
|
||||
from gatehouse_app.services.notification_service import NotificationService
|
||||
|
||||
member_display = user.full_name or user.email
|
||||
inviter_display = invite.invited_by.full_name or invite.invited_by.email
|
||||
org_link = f"{current_app.config.get('APP_URL', '')}/organizations/{invite.organization_id}"
|
||||
|
||||
html_body = build_invite_accepted_html(
|
||||
inviter_name=inviter_display,
|
||||
member_name=member_display,
|
||||
member_email=user.email,
|
||||
org_name=invite.organization.name,
|
||||
role=invite.role,
|
||||
org_link=org_link,
|
||||
)
|
||||
|
||||
NotificationService._send_email_async(
|
||||
to_address=invite.invited_by.email,
|
||||
subject=f"{member_display} accepted your invitation to {invite.organization.name}",
|
||||
body=f"{member_display} has accepted your invitation to join {invite.organization.name} on Secuird.",
|
||||
html_body=html_body,
|
||||
)
|
||||
|
||||
has_webauthn = user.has_webauthn_enabled()
|
||||
has_totp = user.has_totp_enabled()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user