modified: web/blueprints/group_admin.py
modified: web/blueprints/site_admin.py modified: web/mailer.py
This commit is contained in:
@@ -7,7 +7,7 @@ from datetime import datetime, timedelta
|
||||
from functools import wraps
|
||||
from flask import Blueprint, render_template, request, redirect, url_for, session, flash
|
||||
from config import Config
|
||||
from mailer import send_mail
|
||||
from mailer import send_mail, build_invite_email
|
||||
import panel_db as db
|
||||
from roles import GROUP_MANAGEMENT_ROLES, GROUP_ROLE_OPTIONS, GROUP_ROLE_SET, OWNER_ONLY_ROLES, role_label
|
||||
|
||||
@@ -150,14 +150,15 @@ def member_invite():
|
||||
|
||||
if mail_settings:
|
||||
subject = f"Invitation to join {session.get('group_name', 'your group')}"
|
||||
text_body = (
|
||||
f"Hello {username},\n\n"
|
||||
f"You have been invited to join the group '{session.get('group_name', 'your group')}' on MCLogger as {role_label(role)}.\n"
|
||||
f"Open this link to create your account:\n\n{invite_url}\n\n"
|
||||
f"This invite expires in {Config.INVITE_EXPIRY_HOURS} hours.\n"
|
||||
text_body, html_body = build_invite_email(
|
||||
username=username,
|
||||
invite_url=invite_url,
|
||||
expiry_text=f"in {Config.INVITE_EXPIRY_HOURS} hours",
|
||||
group_name=session.get("group_name", "your group"),
|
||||
role_name=role_label(role),
|
||||
)
|
||||
try:
|
||||
send_mail(mail_settings, email, subject, text_body)
|
||||
send_mail(mail_settings, email, subject, text_body, html_body=html_body)
|
||||
if invite:
|
||||
db.mark_group_invite_sent(invite["id"], group_id)
|
||||
flash(f"Invitation email sent to '{email}'.", "success")
|
||||
@@ -193,14 +194,15 @@ def resend_invite(invite_id):
|
||||
|
||||
invite_url = url_for("auth.accept_invite", token=invite["token"], _external=True)
|
||||
subject = f"Invitation to join {session.get('group_name', 'your group')}"
|
||||
text_body = (
|
||||
f"Hello {invite['invited_username']},\n\n"
|
||||
f"You have been invited to join the group '{session.get('group_name', 'your group')}' on MCLogger as {role_label(invite['role'])}.\n"
|
||||
f"Open this link to create your account:\n\n{invite_url}\n\n"
|
||||
f"This invite expires on {invite['expires_at']}.\n"
|
||||
text_body, html_body = build_invite_email(
|
||||
username=invite["invited_username"],
|
||||
invite_url=invite_url,
|
||||
expiry_text=f"on {invite['expires_at']}",
|
||||
group_name=session.get("group_name", "your group"),
|
||||
role_name=role_label(invite["role"]),
|
||||
)
|
||||
try:
|
||||
send_mail(mail_settings, invite["invited_email"], subject, text_body)
|
||||
send_mail(mail_settings, invite["invited_email"], subject, text_body, html_body=html_body)
|
||||
db.mark_group_invite_sent(invite_id, group_id)
|
||||
flash("Invitation email resent.", "success")
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user