feat(api): support variable reference and substitution in Email delivery

The EmailDeliveryConfig.body now support referencing variables generated
by precedent nodes.
This commit is contained in:
QuantumGhost
2026-01-21 15:19:17 +08:00
parent 32dab780ba
commit 20be1dd819
7 changed files with 189 additions and 18 deletions

View File

@ -1,4 +1,5 @@
from core.workflow.nodes.human_input.entities import EmailDeliveryConfig, EmailRecipients
from core.workflow.runtime import VariablePool
def test_replace_url_placeholder_with_value():
@ -23,3 +24,17 @@ def test_replace_url_placeholder_missing_value():
result = config.body_with_url(None)
assert result == "No link available."
def test_render_body_template_replaces_variable_values():
config = EmailDeliveryConfig(
recipients=EmailRecipients(),
subject="Subject",
body="Hello {{#node1.value#}} {{#url#}}",
)
variable_pool = VariablePool()
variable_pool.add(["node1", "value"], "World")
result = config.render_body_template(body=config.body, url="https://example.com", variable_pool=variable_pool)
assert result == "Hello World https://example.com"