in triage-actions/needs-more-info-closer/NeedsMoreInfoCloser.ts [26:80]
for await (const page of this.github.query({ q: query })) {
for (const issue of page) {
const hydrated = await issue.getIssue()
const lastCommentIterator = await issue.getComments(true).next()
if (lastCommentIterator.done) {
throw Error('Unexpected comment data')
}
const lastComment = lastCommentIterator.value[0]
if (
hydrated.open &&
hydrated.labels.includes(this.label)
// TODO: Verify updated timestamp
) {
if (
!lastComment ||
lastComment.author.isGitHubApp ||
// TODO: List the collaborators once per go rather than checking a single user each issue
this.additionalTeam.includes(lastComment.author.name) ||
(await issue.hasWriteAccess(lastComment.author))
) {
if (lastComment) {
safeLog(`Last comment on ${hydrated.number} by team. Closing.`)
} else {
safeLog(`No comments on ${hydrated.number}. Closing.`)
}
if (this.closeComment) {
await issue.postComment(this.closeComment)
}
await issue.closeIssue()
} else {
if (hydrated.updatedAt < pingTimestamp && hydrated.assignee) {
safeLog(
`Last comment on ${hydrated.number} by rando. Pinging @${hydrated.assignee}`,
)
if (this.pingComment) {
await issue.postComment(
this.pingComment
.replace('${assignee}', hydrated.assignee)
.replace('${author}', hydrated.author.name),
)
}
} else {
safeLog(
`Last comment on ${hydrated.number} by rando. Skipping.${
hydrated.assignee ? ' cc @' + hydrated.assignee : ''
}`,
)
}
}
} else {
safeLog('Query returned an invalid issue:' + hydrated.number)
}
}
}