diff --git a/app/auth/views/facebook.py b/app/auth/views/facebook.py index f29213ff..3dc1168b 100644 --- a/app/auth/views/facebook.py +++ b/app/auth/views/facebook.py @@ -7,7 +7,6 @@ from app import email_utils from app.auth.base import auth_bp from app.auth.views.google import create_file_from_url from app.config import URL, FACEBOOK_CLIENT_ID, FACEBOOK_CLIENT_SECRET -from app.email_utils import notify_admin from app.extensions import db from app.log import LOG from app.models import User @@ -109,14 +108,6 @@ def facebook_callback(): flash(f"Welcome to SimpleLogin {user.name}!", "success") - notify_admin( - f"new user {user.name} {user.email} signs up via facebook", - html_content=f""" -name: {user.name}
-email: {user.email}
- """, - ) - # The activation link contains the original page, for ex authorize page if "facebook_next_url" in session: next_url = session["facebook_next_url"] diff --git a/app/auth/views/github.py b/app/auth/views/github.py index 60cb1ea6..6e336daa 100644 --- a/app/auth/views/github.py +++ b/app/auth/views/github.py @@ -1,12 +1,10 @@ from flask import request, session, redirect, url_for, flash -from flask import request, session, redirect, url_for, flash from flask_login import login_user from requests_oauthlib import OAuth2Session from app import email_utils from app.auth.base import auth_bp from app.config import GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, URL -from app.email_utils import notify_admin from app.extensions import db from app.log import LOG from app.models import User @@ -97,13 +95,6 @@ def github_callback(): flash(f"Welcome to SimpleLogin {user.name}!", "success") - notify_admin( - f"new user {user.name} {user.email} signs up via github", - html_content=f""" - name: {user.name}
- email: {user.email}
""", - ) - # The activation link contains the original page, for ex authorize page if "next" in request.args: next_url = request.args.get("next") diff --git a/app/auth/views/google.py b/app/auth/views/google.py index a41aeef4..775f3052 100644 --- a/app/auth/views/google.py +++ b/app/auth/views/google.py @@ -5,7 +5,6 @@ from requests_oauthlib import OAuth2Session from app import s3, email_utils from app.auth.base import auth_bp from app.config import URL, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET -from app.email_utils import notify_admin from app.extensions import db from app.log import LOG from app.models import User, File @@ -108,13 +107,6 @@ def google_callback(): flash(f"Welcome to SimpleLogin {user.name}!", "success") - notify_admin( - f"new user {user.name} {user.email} signs up via google", - html_content=f""" -name: {user.name}
-email: {user.email}
""", - ) - # The activation link contains the original page, for ex authorize page if "google_next_url" in session: next_url = session["google_next_url"] diff --git a/app/auth/views/register.py b/app/auth/views/register.py index b70038ca..7166c301 100644 --- a/app/auth/views/register.py +++ b/app/auth/views/register.py @@ -6,7 +6,6 @@ from wtforms import StringField, validators from app import email_utils from app.auth.base import auth_bp from app.config import URL, EMAIL_DOMAIN -from app.email_utils import notify_admin from app.extensions import db from app.log import LOG from app.models import User, ActivationCode @@ -52,12 +51,6 @@ def register(): db.session.commit() send_activation_email(user, next_url) - notify_admin( - f"new user {user.name} {user.email} signs up via email/password", - html_content=f""" -name: {user.name}
-email: {user.email}
""", - ) return render_template("auth/register_waiting_activation.html") diff --git a/app/dashboard/views/custom_alias.py b/app/dashboard/views/custom_alias.py index 3785d9a1..c0819f50 100644 --- a/app/dashboard/views/custom_alias.py +++ b/app/dashboard/views/custom_alias.py @@ -3,7 +3,6 @@ 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,10 +85,6 @@ 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 b7a77e6e..fc142bbd 100644 --- a/app/dashboard/views/custom_domain.py +++ b/app/dashboard/views/custom_domain.py @@ -6,7 +6,6 @@ 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, get_spf_domain -from app.email_utils import notify_admin from app.extensions import db from app.models import CustomDomain @@ -60,9 +59,7 @@ 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") diff --git a/app/dashboard/views/unsubscribe.py b/app/dashboard/views/unsubscribe.py index e0b0ec0e..068f4857 100644 --- a/app/dashboard/views/unsubscribe.py +++ b/app/dashboard/views/unsubscribe.py @@ -6,7 +6,6 @@ from flask import redirect, url_for, flash, request, render_template from flask_login import login_required, current_user from app.dashboard.base import dashboard_bp -from app.email_utils import notify_admin from app.extensions import db from app.models import GenEmail @@ -32,7 +31,6 @@ def unsubscribe(gen_email_id): flash(f"Alias {gen_email.email} has been blocked", "success") db.session.commit() - notify_admin(f"User {current_user.email} has unsubscribed an alias") return redirect(url_for("dashboard.index")) else: # ask user confirmation return render_template("dashboard/unsubscribe.html", alias=gen_email.email) diff --git a/app/developer/views/new_client.py b/app/developer/views/new_client.py index ed8f55e9..3a403b8a 100644 --- a/app/developer/views/new_client.py +++ b/app/developer/views/new_client.py @@ -5,7 +5,6 @@ from wtforms import StringField, validators from app import email_utils from app.developer.base import developer_bp -from app.email_utils import notify_admin from app.extensions import db from app.log import LOG from app.models import Client @@ -24,15 +23,6 @@ def new_client(): client = Client.create_new(form.name.data, current_user.id) db.session.commit() - notify_admin( - f"user {current_user} created new app {client.name}", - html_content=f""" -name: {current_user.name}
-email: {current_user.email}
-app: {client.name} -""", - ) - flash("Your app has been created", "success") # if this is the first app user creates, sends an email to ask for feedback diff --git a/cron.py b/cron.py index ff89ef2c..04e727d9 100644 --- a/cron.py +++ b/cron.py @@ -3,7 +3,14 @@ import arrow from app import email_utils from app.extensions import db from app.log import LOG -from app.models import Subscription, User, GenEmail, ForwardEmailLog, ForwardEmail +from app.models import ( + Subscription, + User, + GenEmail, + ForwardEmailLog, + ForwardEmail, + CustomDomain, + Client) from server import create_app @@ -60,17 +67,38 @@ def stats(): LOG.d("nb forward %s, nb block %s, nb reply %s", nb_forward, nb_block, nb_reply) + nb_premium = Subscription.query.count() + nb_custom_domain = CustomDomain.query.count() + + nb_custom_domain_alias = GenEmail.query.filter( + GenEmail.custom_domain_id.isnot(None) + ).count() + + nb_disabled_alias = GenEmail.query.filter(GenEmail.enabled == False).count() + + nb_app = Client.query.count() + today = arrow.now().format() email_utils.notify_admin( f"SimpleLogin Stats for {today}", f""" Stats for {today}
+ nb_user: {nb_user}
+nb_premium: {nb_premium}
+ nb_alias: {nb_gen_email}
+nb_disabled_alias: {nb_disabled_alias}
+ +nb_custom_domain: {nb_custom_domain}
+nb_custom_domain_alias: {nb_custom_domain_alias}
+ nb_forward: {nb_forward}
nb_reply: {nb_reply}
nb_block: {nb_block}
+ +nb_app: {nb_app}
""", ) diff --git a/email_handler.py b/email_handler.py index f291cece..e7cd9a20 100644 --- a/email_handler.py +++ b/email_handler.py @@ -39,7 +39,6 @@ from smtplib import SMTP from aiosmtpd.controller import Controller from app.config import EMAIL_DOMAIN, POSTFIX_SERVER, URL -from app.email_utils import notify_admin from app.extensions import db from app.log import LOG from app.models import GenEmail, ForwardEmail, ForwardEmailLog @@ -206,8 +205,6 @@ class MailHandler: forward_email = ForwardEmail.get_by(reply_email=reply_email) alias: str = forward_email.gen_email.email - notify_admin(f"Reply phase used by user: {forward_email.gen_email.user.email} ") - # todo: add DKIM-Signature for custom domain # remove DKIM-Signature for custom domain if not alias.endswith(EMAIL_DOMAIN) and msg["DKIM-Signature"]: diff --git a/server.py b/server.py index 6be66930..92157184 100644 --- a/server.py +++ b/server.py @@ -26,7 +26,6 @@ from app.config import ( from app.dashboard.base import dashboard_bp from app.developer.base import developer_bp from app.discover.base import discover_bp -from app.email_utils import notify_admin from app.extensions import db, login_manager, migrate from app.jose_utils import get_jwk_key from app.log import LOG @@ -326,7 +325,6 @@ def setup_paddle_callback(app: Flask): sub.plan = plan LOG.debug("User %s upgrades!", user) - notify_admin(f"User {user.email} upgrades!") db.session.commit()