Skip to content
This repository was archived by the owner on Feb 3, 2026. It is now read-only.

Commit 109a469

Browse files
committed
feat(server): 支持 issues 事件并优化 webhook 处理逻辑
- 新增对 'issues' 事件的支持,处理并渲染 issue 相关信息 - 优化了对多个事件类型的处理方式,提高代码可维护性 - 调整了日志输出,使错误和警告信息更加清晰
1 parent f6ac0e9 commit 109a469

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

  • src/server/router/github/webhook

src/server/router/github/webhook/index.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ WebHookRouter.post('/', async (req: Request, res: Response) => {
3737
}
3838
}
3939
const event = req.headers['x-github-event'] as string
40-
if (event === 'installation' || event === 'github_app_authorization') {
40+
const ignoreEvents = [
41+
'installation',
42+
'github_app_authorization'
43+
]
44+
if (ignoreEvents.includes(event)) {
4145
return logger.warn('喵呜~, Github App 事件, 跳过推送')
4246
}
4347

@@ -124,8 +128,25 @@ WebHookRouter.post('/', async (req: Request, res: Response) => {
124128
)
125129
break
126130
}
127-
case 'pull_request':
128-
logger.warn(`喵呜~, 暂不支持 ${event} 事件`)
131+
case 'issues':
132+
{
133+
const issue_info = req.body.issue
134+
sendMsg = await Render.render(
135+
'issue/get_issue_info',
136+
{
137+
platform,
138+
owner,
139+
repo,
140+
author_name: issue_info.data.user?.login,
141+
author_avatar: issue_info.data.user?.avatar_url,
142+
issue_number: issue_info.data.id,
143+
issue_state: issue_info.data.state,
144+
issue_title: await base.render_markdown(issue_info.data.title),
145+
issue_body: await base.render_markdown(issue_info.data.body ?? ''),
146+
issue_created_at: await get_relative_time(issue_info.data.created_at)
147+
}
148+
)
149+
}
129150
break
130151
default:
131152
logger.warn(`喵呜~, 不支持的事件类型: ${event}`)

0 commit comments

Comments
 (0)