for await()

in triage-actions/needs-more-info-closer/NeedsMoreInfoCloser.js [22:68]


        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) {
                            utils_1.safeLog(`Last comment on ${hydrated.number} by team. Closing.`);
                        }
                        else {
                            utils_1.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) {
                            utils_1.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 {
                            utils_1.safeLog(`Last comment on ${hydrated.number} by rando. Skipping.${hydrated.assignee ? ' cc @' + hydrated.assignee : ''}`);
                        }
                    }
                }
                else {
                    utils_1.safeLog('Query returned an invalid issue:' + hydrated.number);
                }
            }
        }