部署配置正式登记家具业务系统并保留未列出的已登记项目

This commit is contained in:
chenpei 2026-08-26 15:11:03 +08:00
parent b8a73e963c
commit 1db643daaa
3 changed files with 26 additions and 1 deletions

View File

@ -16,7 +16,7 @@ DINGTALK_LOGIN_TICKET_TTL_SECONDS=60
# 每个项目必须使用不同密钥;allowedHosts 用于限制卡片跳转域名。
# login 省略或 enabled=false 时保持原直接跳转,不启用免登中转。
# 生产环境请使用足够长的随机密钥,不要把真实值提交到 Git。
YYD_NOTIFICATION_PROJECTS_JSON=[{"code":"material_library","name":"素材库","secret":"replace-with-random-secret","allowedHosts":["sc.example.com"]},{"code":"fixed_asset","name":"固定资产","secret":"replace-with-another-random-secret","allowedHosts":["asset.example.com"],"login":{"enabled":true,"callbackUrl":"https://asset.example.com/api/dingtalk/broker-login","allowedRedirectPathPrefixes":["/workflows/disposals","/dashboard"]}}]
YYD_NOTIFICATION_PROJECTS_JSON=[{"code":"material_library","name":"素材库","secret":"replace-with-random-secret","allowedHosts":["sc.example.com"]},{"code":"fixed_asset","name":"固定资产","secret":"replace-with-another-random-secret","allowedHosts":["asset.example.com"],"login":{"enabled":true,"callbackUrl":"https://asset.example.com/api/dingtalk/broker-login","allowedRedirectPathPrefixes":["/workflows/disposals","/dashboard"]}},{"code":"furniture_platform","name":"家具业务系统","secret":"replace-with-furniture-random-secret","allowedHosts":["cp.example.com"]}]
WORKER_ENABLED=true
WORKER_INTERVAL_MS=1000

View File

@ -185,7 +185,27 @@ projects = [
'/inventory',
],
),
project_with_preserved_login(
'furniture_platform',
'家具业务系统',
['cp.jiansun.vip'],
),
]
# 兜底:生产 .env 里已登记、但上面清单未列出的项目原样保留,
# 避免重新部署时把手动登记的接入方从初始化配置中覆盖丢失。
known_codes = {item['code'] for item in projects}
for item in old_projects:
if not isinstance(item, dict):
continue
code = str(item.get('code') or '').strip()
if not code or code in known_codes:
continue
if len(str(item.get('secret') or '')) < 24:
continue
projects.append(dict(item))
known_codes.add(code)
if any(item.get('login', {}).get('enabled') is True for item in projects) and not corp_id:
raise SystemExit('已有项目启用了免登中转,但生产配置缺少 DINGTALK_CORP_ID')

View File

@ -21,6 +21,11 @@ test('生产发布面透传免登配置并保留已有项目 login', () => {
assert.match(deploy, /old_login = by_code\.get\(code, \{\}\)\.get\('login'\)/)
assert.match(deploy, /def project_with_preserved_login/)
assert.match(deploy, /project\['login'\] = login/)
// 家具系统已接入生产;正式登记进初始化清单,防止重部署覆盖。
assert.match(deploy, /'furniture_platform'/)
assert.match(deploy, /'家具业务系统'/)
// 未列出的已登记项目必须原样保留,杜绝同类覆盖事故。
assert.match(deploy, /known_codes = \{item\['code'\] for item in projects\}/)
assert.match(deploy, /docker pause youyidian-notification-center/)
assert.match(deploy, /docker cp youyidian-notification-center:\/app\/data\/\. "\$data_backup\/"/)
assert.match(deploy, /test -s "\$data_backup\/notifications\.db"/)