15m44m 仓库img.json模板webhook_secret挪进repo段去真实值 + loadImgJson读repo.webhook_secret + easy不再被GitHub压制
This commit is contained in:
@@ -99,10 +99,15 @@ function loadImgJson() {
|
||||
$cfg['attach_enabled'] = $attach;
|
||||
}
|
||||
|
||||
// easy = 走 EasyImages2.0(type 非 GitHub 且有 baseurl+key 且附件支持开)
|
||||
$cfg['easy'] = ($cfg['type'] !== 'GitHub' && $cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']);
|
||||
// easy = 走 EasyImages2.0(有 baseurl+key 且附件支持开)
|
||||
// 15m44m 修正:不再被 模式.type=GitHub 压制。type=GitHub 时图床与 issue 同步并存——
|
||||
// 图片照走 EasyImages 图床,工单/回复【额外】同步 GitHub issue(用户 2026-11-25 实测反馈:
|
||||
// type=GitHub 仍走内置工单不跳授权 → 根因是 easy 被压 + 前端根本没接授权按钮)。
|
||||
$cfg['easy'] = ($cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']);
|
||||
|
||||
// GitHub issue 集成(15m44l):repo.url → owner/name + OAuth Client ID/Secret + Webhook 密钥
|
||||
// GitHub issue 集成(15m44m 修正):
|
||||
// webhook_secret 挪进 repo 段(用户明令:仓库 img.json 模板里 webhook_secret 塞进 repo 值,
|
||||
// 顶层不再放敏感值)。优先读 repo.webhook_secret,兜底读顶层 webhook_secret(兼容旧生产文件)。
|
||||
if (isset($j['repo']) && is_array($j['repo'])) {
|
||||
$url = isset($j['repo']['url']) ? trim((string)$j['repo']['url']) : '';
|
||||
// 从 https://github.com/ypsdf1/caoyuanwiki 提取 owner/name(去掉协议+域名+尾斜杠)
|
||||
@@ -113,11 +118,18 @@ function loadImgJson() {
|
||||
$cfg['gh_repo'] = ($repoPath !== '' && strpos($repoPath, '/') !== false) ? $repoPath : '';
|
||||
$cfg['gh_client_id'] = isset($j['repo']['Client ID']) ? trim((string)$j['repo']['Client ID']) : '';
|
||||
$cfg['gh_client_secret'] = isset($j['repo']['Client secrets']) ? trim((string)$j['repo']['Client secrets']) : '';
|
||||
if (isset($j['repo']['webhook_secret'])) {
|
||||
$cfg['gh_webhook_secret'] = trim((string)$j['repo']['webhook_secret']);
|
||||
}
|
||||
}
|
||||
$cfg['gh_webhook_secret'] = isset($j['webhook_secret']) ? trim((string)$j['webhook_secret']) : '';
|
||||
// gh_enabled = 模式.type=GitHub 且 repo 段填全(owner/name + client_id + client_secret)
|
||||
$cfg['gh_enabled'] = ($cfg['type'] === 'GitHub' && $cfg['gh_repo'] !== ''
|
||||
&& $cfg['gh_client_id'] !== '' && $cfg['gh_client_secret'] !== '');
|
||||
if (!isset($j['repo']['webhook_secret'])) {
|
||||
// 兼容旧顶层 webhook_secret(已部署的生产 img.json 可能是旧结构)
|
||||
$cfg['gh_webhook_secret'] = isset($j['webhook_secret']) ? trim((string)$j['webhook_secret']) : '';
|
||||
}
|
||||
// gh_enabled = 模式.type 显式填 GitHub(不再看 repo 段是否填全——模板值/占位值也算已填,
|
||||
// 真正缺配置时 gh_* 为空会让 ghSyncCreate 自动跳过,不影响内置工单入库)。
|
||||
// 用户手动把 模式.type 改成 GitHub 即启用 issue 同步 + 前端授权按钮。
|
||||
$cfg['gh_enabled'] = ($cfg['type'] === 'GitHub');
|
||||
return $cfg;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user