Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/app/services/workflow/triggers/distribution_triggers.py
2026-04-25 02:31:13 +03:30

33 lines
1.3 KiB
Python
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Triggerهای افزونه پخش مویرگی."""
from typing import Any, Dict
from app.services.workflow.triggers.base_trigger import BaseTrigger
class DistributionVisitCompletedTrigger(BaseTrigger):
"""پایان ویزیت میدانی با نتیجه ثبت‌شده."""
def execute(self, context: Dict[str, Any], config: Dict[str, Any]) -> Dict[str, Any]:
trigger_data = context.get("trigger_data") or {}
if config.get("outcome_filter"):
want = str(config["outcome_filter"]).strip().lower()
got = (trigger_data.get("outcome") or "").strip().lower()
if got != want:
return {}
return super().execute(context, config)
def get_metadata(self) -> Dict[str, Any]:
return {
"name": "تکمیل ویزیت میدانی (پخش مویرگی)",
"description": "پس از ثبت نتیجه ویزیت توسط ویزیتور",
"config_schema": {
"enabled": {"type": "boolean", "description": "فعال/غیرفعال", "default": True, "required": False},
"outcome_filter": {
"type": "string",
"description": "فقط اگر نتیجه برابر باشد: order | no_order | cancelled (خالی = همه)",
"required": False,
},
"cooldown_seconds": {"type": "integer", "default": 0, "required": False},
},
}