From e46baa29913c35dd2ebb545636459800249b48e1 Mon Sep 17 00:00:00 2001 From: guohelu <141622458+guohelu@users.noreply.github.com> Date: Tue, 19 Nov 2024 14:23:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=81=94=E8=B0=83bug?= =?UTF-8?q?=20#7545=20(#7612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复联调bug #7545 * fix: 修复返回参数和日志打印问题 #7545 --- gcloud/core/api.py | 1 + gcloud/shortcuts/message/__init__.py | 13 +++++++++---- gcloud/taskflow3/models.py | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gcloud/core/api.py b/gcloud/core/api.py index d006440cf5..2da4ac33e9 100644 --- a/gcloud/core/api.py +++ b/gcloud/core/api.py @@ -165,6 +165,7 @@ def get_msg_types(request): "type": "bk_chat", "icon": None, "label": "bk_chat", + "tips": ("获取群ID方法:\n" "1. 群聊右上角添加联系人: bkchat(蓝鲸信息流)\n" '2. 输入 "小鲸 群ID" 获取群ID\n' "3. 将获取到的群ID粘贴到输入框"), "is_active": True, } result["data"].append(bk_chat) diff --git a/gcloud/shortcuts/message/__init__.py b/gcloud/shortcuts/message/__init__.py index 9cd32ff5d1..6311a98ce6 100644 --- a/gcloud/shortcuts/message/__init__.py +++ b/gcloud/shortcuts/message/__init__.py @@ -31,6 +31,7 @@ def send_task_flow_message(taskflow, msg_type, node_name=""): notify_types = taskflow.get_notify_type() + notify_receivers = taskflow.get_notify_receivers() receivers_list = taskflow.get_stakeholders() receivers = ",".join(receivers_list) executor = taskflow.executor @@ -40,18 +41,22 @@ def send_task_flow_message(taskflow, msg_type, node_name=""): taskflow, taskflow.pipeline_instance, node_name, executor ) notify_type = notify_types.get("fail", []) - notify_info = notify_types.get("extra_info", {}).get("bkchat_groupids", {}).get("fail", "") + notify_info = notify_receivers.get("extra_info", {}).get("bkchat", {}).get("fail", "") elif msg_type == "task_finished": title, content, email_content = title_and_content_for_flow_finished( taskflow, taskflow.pipeline_instance, node_name, executor ) notify_type = notify_types.get("success", []) - notify_info = notify_types.get("extra_info", {}).get("bkchat_groupids", {}).get("success", "") + notify_info = notify_receivers.get("extra_info", {}).get("bkchat", {}).get("success", "") else: return False logger.info( - "taskflow[id={flow_id}] will send {msg_type} message({notify_type}) to: {receivers}".format( - flow_id=taskflow.id, msg_type=msg_type, notify_type=notify_type, receivers=receivers + "taskflow[id={flow_id}] will send {msg_type} message({notify_type}) to: {receivers} {notify_info}".format( + flow_id=taskflow.id, + msg_type=msg_type, + notify_type=notify_type, + receivers=receivers, + notify_info=notify_info, ) ) MessageHandler().send(executor, notify_type, notify_info, receivers, title, content, email_content=email_content) diff --git a/gcloud/taskflow3/models.py b/gcloud/taskflow3/models.py index 20fb804e8e..613d765f87 100644 --- a/gcloud/taskflow3/models.py +++ b/gcloud/taskflow3/models.py @@ -1240,6 +1240,9 @@ def get_stakeholders(self): # 这里保证执行人在列表第一位,且名单中通知人唯一,其他接收人不保证顺序 return sorted(set(receivers), key=receivers.index) + def get_notify_receivers(self): + return json.loads(self.template.notify_receivers) + def get_notify_type(self): notify_type = json.loads(self.template.notify_type) return notify_type if isinstance(notify_type, dict) else {"success": notify_type, "fail": notify_type}