remove notify_admin, replace by general stats

This commit is contained in:
Son NK 2019-12-15 09:52:20 +02:00
parent 0b982a3f19
commit ec62fad3a0
11 changed files with 30 additions and 60 deletions

View File

@ -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} <br>
email: {user.email} <br>
""",
)
# The activation link contains the original page, for ex authorize page
if "facebook_next_url" in session:
next_url = session["facebook_next_url"]

View File

@ -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} <br>
email: {user.email} <br>""",
)
# The activation link contains the original page, for ex authorize page
if "next" in request.args:
next_url = request.args.get("next")

View File

@ -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} <br>
email: {user.email} <br>""",
)
# The activation link contains the original page, for ex authorize page
if "google_next_url" in session:
next_url = session["google_next_url"]

View File

@ -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} <br>
email: {user.email} <br>""",
)
return render_template("auth/register_waiting_activation.html")

View File

@ -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"))

View File

@ -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")

View File

@ -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)

View File

@ -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} <br>
email: {current_user.email} <br>
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

30
cron.py
View File

@ -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} <br>
nb_user: {nb_user} <br>
nb_premium: {nb_premium} <br>
nb_alias: {nb_gen_email} <br>
nb_disabled_alias: {nb_disabled_alias} <br>
nb_custom_domain: {nb_custom_domain} <br>
nb_custom_domain_alias: {nb_custom_domain_alias} <br>
nb_forward: {nb_forward} <br>
nb_reply: {nb_reply} <br>
nb_block: {nb_block} <br>
nb_app: {nb_app} <br>
""",
)

View File

@ -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"]:

View File

@ -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()