diff --git a/gcloud/core/api.py b/gcloud/core/api.py index d006440cf..2da4ac33e 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 9cd32ff5d..6311a98ce 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 20fb804e8..613d765f8 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}