fix(留言分頁): 改用 timeline 分頁讀取留言

Gitea 議題留言端點無法可靠處理分頁;改由 timeline 逐頁篩選 comment 事件並去重,讓抽取、整併與 PR 留言流程取得完整集合。
This commit is contained in:
2026-09-22 14:37:38 +08:00
parent a5699d1798
commit a944141109
5 changed files with 19 additions and 19 deletions
+11 -5
View File
@@ -974,16 +974,22 @@ export async function countUnmergedComments(login, repo, index, me) {
/**
* 逐頁走過一顆議題(或 PR)的一般留言。
* 三支腳本都要做這件事:數未整併的則數、列出留言內容、核對 --merged 的 id。
* Gitea 的 comments 端點固定只回第一批,完整清單改從 timeline 取得。
* @returns {AsyncGenerator<object>} 一則一則交出去
*/
export async function* listIssueComments(login, repo, index) {
const path = `/repos/${repo}/issues/${index}/comments`;
const path = `/repos/${repo}/issues/${index}/timeline`;
const seen = new Set();
for await (const comments of pages(login, path, {
limitCode: 'COMMENT_LIMIT',
limitHint: `${path} 的留言太多,讀不完整份清單`,
for await (const entries of pages(login, path, {
limitCode: 'TIMELINE_LIMIT',
limitHint: `${path} 的 timeline 太多,讀不完整份留言清單`,
})) {
for (const comment of comments) yield comment;
for (const entry of entries) {
if (entry.type !== 'comment' || seen.has(entry.id)) continue;
seen.add(entry.id);
yield entry;
}
}
}