mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 02:09:02 +08:00
feat: add email template for invite new user in workspace (#1810)
This commit is contained in:
parent
695246d80a
commit
1521ac5563
@ -479,6 +479,7 @@ class RegisterService:
|
|||||||
|
|
||||||
# send email
|
# send email
|
||||||
send_invite_member_mail_task.delay(
|
send_invite_member_mail_task.delay(
|
||||||
|
language=account.interface_language,
|
||||||
to=email,
|
to=email,
|
||||||
token=token,
|
token=token,
|
||||||
inviter_name=inviter.name if inviter else 'Dify',
|
inviter_name=inviter.name if inviter else 'Dify',
|
||||||
|
@ -3,21 +3,20 @@ import time
|
|||||||
|
|
||||||
import click
|
import click
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
from flask import current_app
|
from flask import current_app, render_template
|
||||||
|
|
||||||
from extensions.ext_mail import mail
|
from extensions.ext_mail import mail
|
||||||
|
|
||||||
|
|
||||||
@shared_task(queue='mail')
|
@shared_task(queue='mail')
|
||||||
def send_invite_member_mail_task(to: str, token: str, inviter_name: str, workspace_name: str):
|
def send_invite_member_mail_task(language: str, to: str, token: str, inviter_name: str, workspace_name: str):
|
||||||
"""
|
"""
|
||||||
Async Send invite member mail
|
Async Send invite member mail
|
||||||
|
:param language
|
||||||
:param to
|
:param to
|
||||||
:param token
|
:param token
|
||||||
:param inviter_name
|
:param inviter_name
|
||||||
:param workspace_name
|
:param workspace_name
|
||||||
|
|
||||||
Usage: send_invite_member_mail_task.delay(to, token, inviter_name, workspace_name)
|
Usage: send_invite_member_mail_task.delay(langauge, to, token, inviter_name, workspace_name)
|
||||||
"""
|
"""
|
||||||
if not mail.is_inited():
|
if not mail.is_inited():
|
||||||
return
|
return
|
||||||
@ -27,16 +26,22 @@ def send_invite_member_mail_task(to: str, token: str, inviter_name: str, workspa
|
|||||||
start_at = time.perf_counter()
|
start_at = time.perf_counter()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mail.send(
|
url = f'{current_app.config.get("CONSOLE_WEB_URL")}/activate?token={token}'
|
||||||
to=to,
|
if language == 'zh-CN':
|
||||||
subject="{} invited you to join {}".format(inviter_name, workspace_name),
|
html_content = render_template('invite_member_mail_template_zh-CN.html',
|
||||||
html="""<p>Hi there,</p>
|
to=to,
|
||||||
<p>{inviter_name} invited you to join {workspace_name}.</p>
|
inviter_name=inviter_name,
|
||||||
<p>Click <a href="{url}">here</a> to join.</p>
|
workspace_name=workspace_name,
|
||||||
<p>Thanks,</p>
|
url=url)
|
||||||
<p>Dify Team</p>""".format(inviter_name=inviter_name, workspace_name=workspace_name,
|
mail.send(to=to, subject="立即加入 Dify 工作空间", html=html_content)
|
||||||
url=f'{current_app.config.get("CONSOLE_WEB_URL")}/activate?token={token}')
|
else:
|
||||||
)
|
html_content = render_template('invite_member_mail_template_en-US.html',
|
||||||
|
to=to,
|
||||||
|
inviter_name=inviter_name,
|
||||||
|
workspace_name=workspace_name,
|
||||||
|
url=url)
|
||||||
|
mail.send(to=to, subject="Join Dify Workspace Now", html=html_content)
|
||||||
|
|
||||||
|
|
||||||
end_at = time.perf_counter()
|
end_at = time.perf_counter()
|
||||||
logging.info(
|
logging.info(
|
||||||
|
73
api/templates/invite_member_mail_template_en-US.html
Normal file
73
api/templates/invite_member_mail_template_en-US.html
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
line-height: 16pt;
|
||||||
|
color: #374151;
|
||||||
|
background-color: #E5E7EB;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 560px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #F3F4F6;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.header img {
|
||||||
|
max-width: 100px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 12px 24px;
|
||||||
|
background-color: #2970FF;
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-align: center;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
.button:hover {
|
||||||
|
background-color: #265DD4;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: #777777;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</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>
|
||||||
|
<div class="content">
|
||||||
|
<p>Dear {{ to }},</p>
|
||||||
|
<p>{{ inviter_name }} is pleased to invite you to join our workspace on Dify, a platform specifically designed for LLM application development. On Dify, you can explore, create, and collaborate to build and operate AI applications.</p>
|
||||||
|
<p>You can now log in to Dify using the GitHub or Google account associated with this email.</p>
|
||||||
|
<p style="text-align: center;"><a class="button" href="{{ url }}">Login Here</a></p>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p>Best regards,</p>
|
||||||
|
<p>Dify Team</p>
|
||||||
|
<p>Please do not reply directly to this email; it is automatically sent by the system.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
72
api/templates/invite_member_mail_template_zh-CN.html
Normal file
72
api/templates/invite_member_mail_template_zh-CN.html
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Arial', sans-serif;
|
||||||
|
line-height: 16pt;
|
||||||
|
color: #374151;
|
||||||
|
background-color: #E5E7EB;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 560px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #F3F4F6;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.header img {
|
||||||
|
max-width: 100px;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 12px 24px;
|
||||||
|
background-color: #2970FF;
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
text-align: center;
|
||||||
|
transition: background-color 0.3s ease;
|
||||||
|
}
|
||||||
|
.button:hover {
|
||||||
|
background-color: #265DD4;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
font-size: 0.9em;
|
||||||
|
color: #777777;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<img src="https://cloud.dify.ai/logo/logo-site.png" alt="Dify Logo">
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p>尊敬的 {{ to }},</p>
|
||||||
|
<p>{{ inviter_name }} 现邀请您加入我们在 Dify 的工作区,这是一个专为 LLM 应用开发而设计的平台。在 Dify 上,您可以探索、创造和合作,构建和运营 AI 应用。</p>
|
||||||
|
<p>您现在可以使用与此邮件相对应的 GitHub 或 Google 账号登录 Dify。</p>
|
||||||
|
<p style="text-align: center;"><a class="button" href="{{ url }}">在此登录</a></p>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p>此致,</p>
|
||||||
|
<p>Dify 团队</p>
|
||||||
|
<p>请不要直接回复此电子邮件;由系统自动发送。</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
691
web/yarn.lock
691
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user