dify/api/tasks/mail_workflow_comment_task.py
Yansong Zhang 44491e427c feat(api): enable all sandbox/skill controller routes and resolve dependencies (P0)
Resolve the full dependency chain to enable all previously disabled controllers:

Enabled routes:
- sandbox_files: sandbox file browser API
- sandbox_providers: sandbox provider management API
- app_asset: app asset management API
- skills: skill extraction API
- CLI API blueprint: DifyCli callback endpoints (/cli/api/*)

Dependencies extracted (64 files, ~8000 lines):
- models/sandbox.py, models/app_asset.py: DB models
- core/zip_sandbox/: zip-based sandbox execution
- core/session/: CLI API session management
- core/memory/: base memory + node token buffer
- core/helper/creators.py: helper utilities
- core/llm_generator/: context models, output models, utils
- core/workflow/nodes/command/: command node type
- core/workflow/nodes/file_upload/: file upload node type
- core/app/entities/: app_asset_entities, app_bundle_entities, llm_generation_entities
- services/: asset_content, skill, workflow_collaboration, workflow_comment
- controllers/console/app/error.py: AppAsset error classes
- core/tools/utils/system_encryption.py

Import fixes:
- dify_graph.enums -> graphon.enums in skill_service.py
- get_signed_file_url_for_plugin -> get_signed_file_url in cli_api.py

All 5 controllers verified: import OK, Flask starts successfully.
46 existing tests still pass.

Made-with: Cursor
2026-04-09 09:36:16 +08:00

66 lines
1.9 KiB
Python

import logging
import time
import click
from celery import shared_task
from extensions.ext_mail import mail
from libs.email_i18n import EmailType, get_email_i18n_service
logger = logging.getLogger(__name__)
@shared_task(queue="mail")
def send_workflow_comment_mention_email_task(
language: str,
to: str,
mentioned_name: str,
commenter_name: str,
app_name: str,
comment_content: str,
app_url: str,
):
"""
Send workflow comment mention email with internationalization support.
Args:
language: Language code for email localization
to: Recipient email address
mentioned_name: Name of the mentioned user
commenter_name: Name of the comment author
app_name: Name of the app where the comment was made
comment_content: Comment content excerpt
app_url: Link to the app workflow page
"""
if not mail.is_inited():
return
logger.info(click.style(f"Start workflow comment mention mail to {to}", fg="green"))
start_at = time.perf_counter()
try:
email_service = get_email_i18n_service()
email_service.send_email(
email_type=EmailType.WORKFLOW_COMMENT_MENTION,
language_code=language,
to=to,
template_context={
"to": to,
"mentioned_name": mentioned_name,
"commenter_name": commenter_name,
"app_name": app_name,
"comment_content": comment_content,
"app_url": app_url,
},
)
end_at = time.perf_counter()
logger.info(
click.style(
f"Send workflow comment mention mail to {to} succeeded: latency: {end_at - start_at}",
fg="green",
)
)
except Exception:
logger.exception("workflow comment mention email to %s failed", to)