Skip to content

Commit

Permalink
fix: 修复联调bug #7545 (#7612)
Browse files Browse the repository at this point in the history
* fix: 修复联调bug #7545

* fix: 修复返回参数和日志打印问题 #7545
  • Loading branch information
guohelu authored Nov 19, 2024
1 parent 2772da8 commit e46baa2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions gcloud/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions gcloud/shortcuts/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions gcloud/taskflow3/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit e46baa2

Please sign in to comment.