feat: 支持按项目配置钉钉通知 @ 名单
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a4cd855b0c
commit
10c39b5116
@@ -23,7 +23,7 @@ from ..config import (
|
||||
from ..projects import LEGACY_PROJECT_ID, PATCHER_READOOR, get_definition, get_project_source
|
||||
from .log_streamer import log_streamer
|
||||
from .distribution import DistributionError, publish_dsym, publish_ipa
|
||||
from .notification import NotificationError, send_dingtalk_notification
|
||||
from .notification import NotificationError, merge_project_at_mobiles, send_dingtalk_notification
|
||||
from .project_patcher import ProjectPatchError, apply_project_config
|
||||
|
||||
|
||||
@@ -553,9 +553,13 @@ async def run_build_task(task_id: str):
|
||||
await log_streamer.emit(task_id, f"下载链接: {task.oss_url}")
|
||||
|
||||
# Ad Hoc 发安装页二维码通知,App Store 发 IPA 下载地址通知;
|
||||
# 两者标题与 @ 名单不同,均由 send_dingtalk_notification 按 BUILD_TYPE 区分。
|
||||
# 两者标题与 @ 名单不同,均由 send_dingtalk_notification 按 BUILD_TYPE 区分;
|
||||
# 项目配置了 @ 名单时覆盖全局名单。
|
||||
# 通知不影响已完成的打包结果,发送失败仅写入日志以便排查。
|
||||
dingtalk_config = config_data.get("_upload_config", {}).get("dingtalk", {})
|
||||
dingtalk_config = merge_project_at_mobiles(
|
||||
config_data.get("_upload_config", {}).get("dingtalk", {}),
|
||||
definition.get("dingtalk_at"),
|
||||
)
|
||||
try:
|
||||
notified = await asyncio.to_thread(
|
||||
send_dingtalk_notification,
|
||||
|
||||
@@ -27,7 +27,7 @@ def _signed_webhook_url(webhook_url: str, secret: str) -> str:
|
||||
return f"{webhook_url}{separator}timestamp={timestamp}&sign={quote(base64.b64encode(signature))}"
|
||||
|
||||
|
||||
def _normalize_mobiles(at_mobiles) -> list:
|
||||
def normalize_mobiles(at_mobiles) -> list:
|
||||
"""把手机号配置统一成去重、去空的字符串列表,兼容列表或逗号/换行分隔的字符串。"""
|
||||
if not at_mobiles:
|
||||
return []
|
||||
@@ -43,6 +43,20 @@ def _normalize_mobiles(at_mobiles) -> list:
|
||||
return seen
|
||||
|
||||
|
||||
# Ad_Hoc / App_Store 两份 @ 名单在配置中的键名
|
||||
AT_MOBILES_KEYS = ("at_mobiles", "at_mobiles_app_store")
|
||||
|
||||
|
||||
def merge_project_at_mobiles(dingtalk_config: dict, project_at: dict) -> dict:
|
||||
"""项目配置了 @ 名单时覆盖全局名单(按打包类型分别覆盖),为空则沿用全局名单。"""
|
||||
merged = dict(dingtalk_config or {})
|
||||
for key in AT_MOBILES_KEYS:
|
||||
mobiles = normalize_mobiles((project_at or {}).get(key))
|
||||
if mobiles:
|
||||
merged[key] = mobiles
|
||||
return merged
|
||||
|
||||
|
||||
def build_dingtalk_payload(
|
||||
config_data: dict,
|
||||
download_url: str,
|
||||
@@ -50,7 +64,7 @@ def build_dingtalk_payload(
|
||||
at_mobiles=None,
|
||||
) -> dict:
|
||||
"""生成与 AutoPacking/upload_iap.py 一致的钉钉 Markdown 内容。"""
|
||||
mobiles = _normalize_mobiles(at_mobiles)
|
||||
mobiles = normalize_mobiles(at_mobiles)
|
||||
# App_Store 包与 Ad Hoc 用不同标题,App_Store 只有 IPA 下载地址、无二维码。
|
||||
# 标题必须保留「打包」二字:钉钉机器人启用了自定义关键词,缺少关键词会被拒收。
|
||||
heading = "【iOS】App_Store 打包信息" if config_data.get("BUILD_TYPE") == "App_Store" else "【iOS】打包信息"
|
||||
|
||||
Reference in New Issue
Block a user