notify admin when user creates new custom domain or custom alias associated with custom domain

This commit is contained in:
Son NK 2019-12-02 00:36:47 +00:00
parent 0234af03d3
commit 3f189163dd
2 changed files with 9 additions and 0 deletions

View File

@ -3,6 +3,7 @@ from flask_login import login_required, current_user
from app.config import EMAIL_DOMAIN, HIGHLIGHT_GEN_EMAIL_ID
from app.dashboard.base import dashboard_bp
from app.email_utils import notify_admin
from app.extensions import db
from app.log import LOG
from app.models import GenEmail, DeletedAlias, CustomDomain
@ -86,6 +87,10 @@ def custom_alias():
db.session.commit()
flash(f"Alias {full_email} has been created", "success")
notify_admin(
f"User {current_user.email} creates new alias for domain {custom_domain.domain}"
)
session[HIGHLIGHT_GEN_EMAIL_ID] = gen_email.id
return redirect(url_for("dashboard.index"))

View File

@ -6,6 +6,7 @@ from wtforms import StringField, validators
from app.config import EMAIL_SERVERS_WITH_PRIORITY, EMAIL_SERVERS
from app.dashboard.base import dashboard_bp
from app.dns_utils import get_mx_domains
from app.email_utils import notify_admin
from app.extensions import db
from app.models import CustomDomain
@ -54,6 +55,9 @@ def custom_domain():
f"New domain {new_custom_domain.domain} has been created successfully",
"success",
)
notify_admin(
f"User {current_user.email} creates new domain {new_custom_domain.domain}"
)
return redirect(url_for("dashboard.custom_domain"))
elif request.form.get("form-name") == "check-domain":
custom_domain_id = request.form.get("custom-domain-id")