refactor: rename allow-permissions (#48)

* refactor: rename allow-permissions

* up
This commit is contained in:
xrkffgg
2021-01-26 21:50:10 +08:00
committed by GitHub
parent f777971d6d
commit 1425c335af
8 changed files with 69 additions and 29 deletions

View File

@@ -8,7 +8,12 @@ const ALLREACTIONS = ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocke
const { doQueryIssues } = require('./public.js');
const { dealStringToArr, dealRandomAssignees, testDuplicate } = require('./util.js');
const {
dealStringToArr,
dealRandomAssignees,
testDuplicate,
checkPermission,
} = require('./util.js');
// **************************************************************************
const token = core.getInput('token');
@@ -146,7 +151,7 @@ async function doMarkDuplicate(owner, repo, labels) {
const duplicateLabels = core.getInput('duplicate-labels');
const removeLables = core.getInput('remove-labels');
const closeIssue = core.getInput('close-issue');
const allowPermissions = core.getInput('allow-permissions');
const requirePermission = core.getInput('require-permission');
const commentId = context.payload.comment.id;
const commentBody = context.payload.comment.body;
@@ -155,14 +160,14 @@ async function doMarkDuplicate(owner, repo, labels) {
const ifCommandInput = !!duplicateCommand;
if (allowPermissions) {
if (requirePermission) {
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!allowPermissions.includes(permission)) {
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}