parent
309a15d1ba
commit
74d3320519
@ -0,0 +1,26 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
from celery import shared_task # type: ignore
|
||||||
|
|
||||||
|
from extensions.ext_database import db
|
||||||
|
from models.account import Account
|
||||||
|
from services.billing_service import BillingService
|
||||||
|
from tasks.mail_account_deletion_task import send_deletion_success_task
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@shared_task(queue="dataset")
|
||||||
|
def delete_account_task(account_id):
|
||||||
|
account = db.session.query(Account).filter(Account.id == account_id).first()
|
||||||
|
try:
|
||||||
|
BillingService.delete_account(account_id)
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(f"Failed to delete account {account_id} from billing service.")
|
||||||
|
raise
|
||||||
|
|
||||||
|
if not account:
|
||||||
|
logger.error(f"Account {account_id} not found.")
|
||||||
|
return
|
||||||
|
# send success email
|
||||||
|
send_deletion_success_task.delay(account.email)
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
import click
|
||||||
|
from celery import shared_task # type: ignore
|
||||||
|
from flask import render_template
|
||||||
|
|
||||||
|
from extensions.ext_mail import mail
|
||||||
|
|
||||||
|
|
||||||
|
@shared_task(queue="mail")
|
||||||
|
def send_deletion_success_task(to):
|
||||||
|
"""Send email to user regarding account deletion.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
log (AccountDeletionLog): Account deletion log object
|
||||||
|
"""
|
||||||
|
if not mail.is_inited():
|
||||||
|
return
|
||||||
|
|
||||||
|
logging.info(click.style(f"Start send account deletion success email to {to}", fg="green"))
|
||||||
|
start_at = time.perf_counter()
|
||||||
|
|
||||||
|
try:
|
||||||
|
html_content = render_template(
|
||||||
|
"delete_account_success_template_en-US.html",
|
||||||
|
to=to,
|
||||||
|
email=to,
|
||||||
|
)
|
||||||
|
mail.send(to=to, subject="Your Dify.AI Account Has Been Successfully Deleted", html=html_content)
|
||||||
|
|
||||||
|
end_at = time.perf_counter()
|
||||||
|
logging.info(
|
||||||
|
click.style(
|
||||||
|
"Send account deletion success email to {}: latency: {}".format(to, end_at - start_at), fg="green"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
logging.exception("Send account deletion success email to {} failed".format(to))
|
||||||
|
|
||||||
|
|
||||||
|
@shared_task(queue="mail")
|
||||||
|
def send_account_deletion_verification_code(to, code):
|
||||||
|
"""Send email to user regarding account deletion verification code.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
to (str): Recipient email address
|
||||||
|
code (str): Verification code
|
||||||
|
"""
|
||||||
|
if not mail.is_inited():
|
||||||
|
return
|
||||||
|
|
||||||
|
logging.info(click.style(f"Start send account deletion verification code email to {to}", fg="green"))
|
||||||
|
start_at = time.perf_counter()
|
||||||
|
|
||||||
|
try:
|
||||||
|
html_content = render_template("delete_account_code_email_template_en-US.html", to=to, code=code)
|
||||||
|
mail.send(to=to, subject="Dify.AI Account Deletion and Verification", html=html_content)
|
||||||
|
|
||||||
|
end_at = time.perf_counter()
|
||||||
|
logging.info(
|
||||||
|
click.style(
|
||||||
|
"Send account deletion verification code email to {} succeeded: latency: {}".format(
|
||||||
|
to, end_at - start_at
|
||||||
|
),
|
||||||
|
fg="green",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
logging.exception("Send account deletion verification code email to {} failed".format(to))
|
||||||
@ -0,0 +1,125 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
line-height: 16pt;
|
||||||
|
color: #101828;
|
||||||
|
background-color: #e9ebf0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: 600px;
|
||||||
|
min-height: 605px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 36px 48px;
|
||||||
|
background-color: #fcfcfd;
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid #ffffff;
|
||||||
|
box-shadow: 0 2px 4px -2px rgba(9, 9, 11, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header img {
|
||||||
|
max-width: 100px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 28.8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 16px;
|
||||||
|
color: #676f83;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-content {
|
||||||
|
padding: 16px 32px;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 16px;
|
||||||
|
background-color: #f2f4f7;
|
||||||
|
margin: 16px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code {
|
||||||
|
line-height: 36px;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tips {
|
||||||
|
line-height: 16px;
|
||||||
|
color: #676f83;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typography {
|
||||||
|
letter-spacing: -0.07px;
|
||||||
|
font-weight: 400;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 20px;
|
||||||
|
color: #354052;
|
||||||
|
margin-top: 12px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
.typography p{
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.typography-title {
|
||||||
|
color: #101828;
|
||||||
|
font-size: 14px;
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
margin-top: 12px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
.tip-list{
|
||||||
|
margin: 0;
|
||||||
|
padding-left: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<!-- Optional: Add a logo or a header image here -->
|
||||||
|
<img src="https://cloud.dify.ai/logo/logo-site.png" alt="Dify Logo" />
|
||||||
|
</div>
|
||||||
|
<p class="title">Dify.AI Account Deletion and Verification</p>
|
||||||
|
<p class="typography">We received a request to delete your Dify account. To ensure the security of your account and
|
||||||
|
confirm this action, please use the verification code below:</p>
|
||||||
|
<div class="code-content">
|
||||||
|
<span class="code">{{code}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="typography">
|
||||||
|
<p style="margin-bottom:4px">To complete the account deletion process:</p>
|
||||||
|
<p>1. Return to the account deletion page on our website</p>
|
||||||
|
<p>2. Enter the verification code above</p>
|
||||||
|
<p>3. Click "Confirm Deletion"</p>
|
||||||
|
</div>
|
||||||
|
<p class="typography-title">Please note:</p>
|
||||||
|
<ul class="typography tip-list">
|
||||||
|
<li>This code is valid for 5 minutes</li>
|
||||||
|
<li>As the Owner of any Workspaces, your workspaces will be scheduled in a queue for permanent deletion.</li>
|
||||||
|
<li>All your user data will be queued for permanent deletion.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
line-height: 16pt;
|
||||||
|
color: #101828;
|
||||||
|
background-color: #e9ebf0;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: 600px;
|
||||||
|
min-height: 380px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 36px 48px;
|
||||||
|
background-color: #fcfcfd;
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid #ffffff;
|
||||||
|
box-shadow: 0 2px 4px -2px rgba(9, 9, 11, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header img {
|
||||||
|
max-width: 100px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 28.8px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
color: #354052;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code-content {
|
||||||
|
padding: 16px 32px;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 16px;
|
||||||
|
background-color: #f2f4f7;
|
||||||
|
margin: 16px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.code {
|
||||||
|
line-height: 36px;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tips {
|
||||||
|
line-height: 16px;
|
||||||
|
color: #676f83;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.email {
|
||||||
|
color: #354052;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.typography{
|
||||||
|
font-weight: 400;
|
||||||
|
font-style: normal;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 20px;
|
||||||
|
color: #354052;
|
||||||
|
margin-top: 4px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<!-- Optional: Add a logo or a header image here -->
|
||||||
|
<img src="https://cloud.dify.ai/logo/logo-site.png" alt="Dify Logo" />
|
||||||
|
</div>
|
||||||
|
<p class="title">Your Dify.AI Account Has Been Successfully Deleted</p>
|
||||||
|
<p class="typography">We're writing to confirm that your Dify.AI account has been successfully deleted as per your request. Your
|
||||||
|
account is no longer accessible, and you can't log in using your previous credentials. If you decide to use
|
||||||
|
Dify.AI services in the future, you'll need to create a new account after 30 days. We appreciate the time you
|
||||||
|
spent with Dify.AI and are sorry to see you go. If you have any questions or concerns about the deletion process,
|
||||||
|
please don't hesitate to reach out to our support team.</p>
|
||||||
|
<p class="typography">Thank you for being a part of the Dify.AI community.</p>
|
||||||
|
<p class="typography">Best regards,</p>
|
||||||
|
<p class="typography">Dify.AI Team</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue