15m44l 工单第二批: GitHub issue 双向同步(OAuth逐次授权+建issue/评论+Webhook回推, 防循环前缀)
This commit is contained in:
@@ -39,11 +39,14 @@ if (!defined('LSKY_ALLOWED_HOST_PREFIX')) {
|
||||
* 图像/附件支持.最大图片数量 — 单工单最多几张(默认 3)
|
||||
* 图像/附件支持.最大大小 — 单张大小上限, 单位 MB(默认 2)
|
||||
* 图像/附件支持.后缀格式 — 允许的后缀数组(默认 ["jpg","jpeg","png"])
|
||||
* 模式.type — 留空=图床, GitHub=issue(本期不做)
|
||||
* 模式.type — 留空=图床, GitHub=issue
|
||||
* repo.url / Client ID / Client secrets — GitHub OAuth App(issue 集成)
|
||||
* webhook_secret — GitHub Webhook 签名密钥(X-Hub-Signature-256)
|
||||
*
|
||||
* 返回结构(统一):
|
||||
* ['type','baseurl','key','easy',
|
||||
* 'attach_enabled','max_images','max_size_mb','allowed_exts']
|
||||
* 'attach_enabled','max_images','max_size_mb','allowed_exts',
|
||||
* 'gh_enabled','gh_repo','gh_client_id','gh_client_secret','gh_webhook_secret']
|
||||
* 文件缺失/解析失败 → 全默认值(调用方按"未配置"兜底)。
|
||||
*/
|
||||
function loadImgJson() {
|
||||
@@ -57,6 +60,12 @@ function loadImgJson() {
|
||||
'max_images' => 3,
|
||||
'max_size_mb' => 2,
|
||||
'allowed_exts' => ['jpg', 'jpeg', 'png'],
|
||||
// GitHub issue 集成(15m44l 第二批)
|
||||
'gh_enabled' => false,
|
||||
'gh_repo' => '', // "ypsdf1/caoyuanwiki"
|
||||
'gh_client_id' => '',
|
||||
'gh_client_secret' => '',
|
||||
'gh_webhook_secret' => '',
|
||||
];
|
||||
$file = __DIR__ . '/img.json';
|
||||
if (!is_readable($file)) return $cfg;
|
||||
@@ -92,6 +101,23 @@ function loadImgJson() {
|
||||
|
||||
// easy = 走 EasyImages2.0(type 非 GitHub 且有 baseurl+key 且附件支持开)
|
||||
$cfg['easy'] = ($cfg['type'] !== 'GitHub' && $cfg['baseurl'] !== '' && $cfg['key'] !== '' && $cfg['attach_enabled']);
|
||||
|
||||
// GitHub issue 集成(15m44l):repo.url → owner/name + OAuth Client ID/Secret + Webhook 密钥
|
||||
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(去掉协议+域名+尾斜杠)
|
||||
$repoPath = $url;
|
||||
$repoPath = preg_replace('#^https?://#i', '', $repoPath);
|
||||
$repoPath = preg_replace('#^github\.com/#i', '', $repoPath);
|
||||
$repoPath = trim($repoPath, '/');
|
||||
$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']) : '';
|
||||
}
|
||||
$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'] !== '');
|
||||
return $cfg;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user