From 3f189163dd3d34c1adbf8dc2cb4fac7134866469 Mon Sep 17 00:00:00 2001 From: Son NK Date: Mon, 2 Dec 2019 00:36:47 +0000 Subject: [PATCH] notify admin when user creates new custom domain or custom alias associated with custom domain --- app/dashboard/views/custom_alias.py | 5 +++++ app/dashboard/views/custom_domain.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/app/dashboard/views/custom_alias.py b/app/dashboard/views/custom_alias.py index 56f6a14f..fec1be7a 100644 --- a/app/dashboard/views/custom_alias.py +++ b/app/dashboard/views/custom_alias.py @@ -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")) diff --git a/app/dashboard/views/custom_domain.py b/app/dashboard/views/custom_domain.py index ede6a8fc..da9c05d6 100644 --- a/app/dashboard/views/custom_domain.py +++ b/app/dashboard/views/custom_domain.py @@ -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")