15m44z 第三部分: GitHub App bot 匿名工单 + 匿名/实名开关 + 归属派发
【匿名工单主体】 - App 鉴权: gh_api.php 新增 ghAppJwt(PEM签RS256 JWT)+ghAppInstallationToken(换1h installation token, 缓存到 /plugin/gh_app_token_cache.json 55min)+ghAppBotReady。 - 匿名代发: 用 installation token(g hs_前缀)建 issue 归属 bot(caoyuan-server[bot]), 不暴露提单人 GitHub 账号; 提单人信息写 issue 正文「玩家:xxx」+ PHP 后台保留。 - loadImgJson 解析 repo.imgrepo."github app"(appid/安装id/私钥路径/匿名模式)。 【匿名/实名开关(用户定调: 共存, 做成开关)】 - json「匿名模式」字段(github app 段): true=gh模式支持匿名(前端出开关); false=gh模式 一律实名授权(即使 appbot 配了也不给匿名选项)。 - 前端: gh_anon_available=true(匿名模式开+appbot可用)才显示「匿名工单」开关; 开关开→提交带 anon=1(bot代发), 关→走玩家OAuth建单; 模式留空(PHP内置工单)不给匿名。 - 建单: anon=1 且匿名模式开→appbot token; 否则玩家 OAuth token。 【归属派发(用户定调: 按工单所有人)】 - ghSyncCreate 建 issue 后回写 gh_issue_owner(bot/realname, 按 token 前缀 ghs_/gho_)。 - 撤单/完结/回复按 ghTicketTokenByTicket 归属: bot建的单→机器人代发撤/完结/评论; 实名单→玩家 OAuth token(保持现有逻辑)。 实测: App JWT→installation token→建issue#24(归属caoyuan-server[bot])全链路通; 线上 gh_cfg 返回 gh_anon_available=true。6件PHP+img.json模板+真值img.json+私钥全MATCH。
This commit is contained in:
@@ -189,6 +189,33 @@ function loadImgJson() {
|
||||
$parts = explode('/', $cfg['imgrepo_full']);
|
||||
$cfg['imgrepo_owner'] = $parts[0];
|
||||
}
|
||||
// ★ 15m44z 第三部分:GitHub App bot(匿名工单)凭证。
|
||||
// repo.imgrepo."github app" 段:appid / 安装 id / 私钥路径。
|
||||
// 仓库版 img.json 填占位(appid=88888 等),.workbuddy 真值版填真凭证。
|
||||
// appid 非占位 → 工单走 appbot 代发(issue 归属 bot,提单人匿名)。
|
||||
// 私钥路径:绝对路径原样;相对路径拼 Web 根目录(__DIR__=/plugin)。
|
||||
$app = isset($ir['github app']) && is_array($ir['github app']) ? $ir['github app'] : null;
|
||||
if ($app !== null) {
|
||||
$ghAppId = trim((string)($app['appid'] ?? ($app['Client ID'] ?? '')));
|
||||
$cfg['gh_app_id'] = $ghAppId;
|
||||
$cfg['gh_app_installation_id'] = trim((string)($app['安装 id'] ?? $app['installation_id'] ?? ''));
|
||||
$cfg['gh_app_bot'] = !empty($ghAppId) && $ghAppId !== '88888' && $ghAppId !== 'example';
|
||||
// ★ 15m44z 第三部分+开关:「匿名模式」字段——true=gh模式支持匿名工单(前端出开关);
|
||||
// false=gh模式一律实名授权(即使 appbot 配了也不给匿名选项)。缺省按 true。
|
||||
$anonRaw = $app['匿名模式'] ?? true;
|
||||
if (is_bool($anonRaw)) {
|
||||
$cfg['gh_anon_mode'] = $anonRaw;
|
||||
} else {
|
||||
$cfg['gh_anon_mode'] = !(strtolower(trim((string)$anonRaw)) === 'false'
|
||||
|| (string)$anonRaw === '0' || $anonRaw === 0);
|
||||
}
|
||||
$pemPath = trim((string)($app['私钥'] ?? ''));
|
||||
if ($pemPath !== '' && !preg_match('#^[A-Za-z]:[\\\\/]#', $pemPath)
|
||||
&& !preg_match('#^/|^\\\\#', $pemPath) && strpos($pemPath, '://') !== 0) {
|
||||
$pemPath = __DIR__ . '/' . $pemPath;
|
||||
}
|
||||
$cfg['gh_app_pem_path'] = $pemPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($j['repo']['webhook_secret'])) {
|
||||
|
||||
Reference in New Issue
Block a user