feat: The definition of attribute choice values supports webhook and other model attribute values.

This commit is contained in:
pycook
2023-10-09 15:33:18 +08:00
parent c0541b7e50
commit ef90506916
9 changed files with 107 additions and 41 deletions

View File

@@ -3,6 +3,7 @@
import json
import requests
import six
from flask import current_app
from jinja2 import Template
from markdownify import markdownify as md
@@ -17,7 +18,15 @@ def _request_messenger(subject, body, tos, sender, payload):
if not params['tos']:
raise Exception("no receivers")
params['tos'] = [Template(i).render(payload) for i in params['tos'] if i.strip()]
flat_tos = []
for i in params['tos']:
if i.strip():
to = Template(i).render(payload)
if isinstance(to, list):
flat_tos.extend(to)
elif isinstance(to, six.string_types):
flat_tos.append(to)
params['tos'] = flat_tos
if sender == "email":
params['msgtype'] = 'text/html'