fix: api request limit (#57)

This commit is contained in:
xrkffgg
2021-02-03 00:34:17 +08:00
committed by GitHub
parent 14e4762bf5
commit 1efbf3d3cf
2 changed files with 24 additions and 23 deletions

25
dist/index.js vendored
View File

@@ -8005,7 +8005,7 @@ async function doCreateLabel(owner, repo) {
}); });
core.info(`Actions: [create-label][${name}] success!`); core.info(`Actions: [create-label][${name}] success!`);
} catch (err) { } catch (err) {
console.log(err.message) console.log(err.message);
} }
} }
@@ -8053,17 +8053,6 @@ async function doMarkDuplicate(owner, repo, labels) {
const ifCommandInput = !!duplicateCommand; const ifCommandInput = !!duplicateCommand;
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
if ( if (
!commentBody.includes('?') && !commentBody.includes('?') &&
((ifCommandInput && ((ifCommandInput &&
@@ -8071,6 +8060,18 @@ async function doMarkDuplicate(owner, repo, labels) {
commentBody.split(' ')[0] == duplicateCommand) || commentBody.split(' ')[0] == duplicateCommand) ||
testDuplicate(commentBody)) testDuplicate(commentBody))
) { ) {
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
if (ifCommandInput) { if (ifCommandInput) {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);

View File

@@ -190,17 +190,6 @@ async function doMarkDuplicate(owner, repo, labels) {
const ifCommandInput = !!duplicateCommand; const ifCommandInput = !!duplicateCommand;
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
if ( if (
!commentBody.includes('?') && !commentBody.includes('?') &&
((ifCommandInput && ((ifCommandInput &&
@@ -208,6 +197,17 @@ async function doMarkDuplicate(owner, repo, labels) {
commentBody.split(' ')[0] == duplicateCommand) || commentBody.split(' ')[0] == duplicateCommand) ||
testDuplicate(commentBody)) testDuplicate(commentBody))
) { ) {
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
if (ifCommandInput) { if (ifCommandInput) {
const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of'); const nextBody = commentBody.replace(duplicateCommand, 'Duplicate of');
await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true); await doUpdateComment(owner, repo, commentId, nextBody, 'replace', true);