mirror of
https://github.com/langgenius/dify.git
synced 2026-01-14 06:07:33 +08:00
Some checks are pending
autofix.ci / autofix (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/amd64, build-api-amd64) (push) Waiting to run
Build and Push API & Web / build (api, DIFY_API_IMAGE_NAME, linux/arm64, build-api-arm64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/amd64, build-web-amd64) (push) Waiting to run
Build and Push API & Web / build (web, DIFY_WEB_IMAGE_NAME, linux/arm64, build-web-arm64) (push) Waiting to run
Build and Push API & Web / create-manifest (api, DIFY_API_IMAGE_NAME, merge-api-images) (push) Blocked by required conditions
Build and Push API & Web / create-manifest (web, DIFY_WEB_IMAGE_NAME, merge-web-images) (push) Blocked by required conditions
31 lines
1010 B
Python
31 lines
1010 B
Python
import logging
|
|
import time
|
|
from collections.abc import Mapping
|
|
|
|
import click
|
|
from celery import shared_task
|
|
from flask import render_template_string
|
|
|
|
from extensions.ext_mail import mail
|
|
from libs.email_i18n import get_email_i18n_service
|
|
|
|
|
|
@shared_task(queue="mail")
|
|
def send_inner_email_task(to: list[str], subject: str, body: str, substitutions: Mapping[str, str]):
|
|
if not mail.is_inited():
|
|
return
|
|
|
|
logging.info(click.style(f"Start enterprise mail to {to} with subject {subject}", fg="green"))
|
|
start_at = time.perf_counter()
|
|
|
|
try:
|
|
html_content = render_template_string(body, **substitutions)
|
|
|
|
email_service = get_email_i18n_service()
|
|
email_service.send_raw_email(to=to, subject=subject, html_content=html_content)
|
|
|
|
end_at = time.perf_counter()
|
|
logging.info(click.style(f"Send enterprise mail to {to} succeeded: latency: {end_at - start_at}", fg="green"))
|
|
except Exception:
|
|
logging.exception("Send enterprise mail to %s failed", to)
|