diff --git a/services/GithubService.js b/services/GithubService.js index 8cfac87..6023d4f 100644 --- a/services/GithubService.js +++ b/services/GithubService.js @@ -221,7 +221,7 @@ async function getUserIdByLogin(copilot, login) { Joi.attempt({copilot, login}, getUserIdByLogin.schema); const github = await _authenticate(copilot.accessToken); const user = await github.users.getForUser({username: login}); - return user.length ? user.id : null; + return user.data ? user.data.id : null; } getUserIdByLogin.schema = { diff --git a/services/IssueService.js b/services/IssueService.js index 1381529..ce3fc46 100755 --- a/services/IssueService.js +++ b/services/IssueService.js @@ -211,6 +211,12 @@ async function handleIssueAssignment(event, issue, force = false) { return; } + // The issue has registered assignee. Ignore it. + // If there is assignee changes, it will be handled at handleIssueUnassignment and this func will be called again. + if (dbIssue.assignee) { + return; + } + // ensure issue has open for pickup label const hasOpenForPickupLabel = _(issue.labels).includes(config.OPEN_FOR_PICKUP_ISSUE_LABEL); // eslint-disable-line lodash/chaining const hasNotReadyLabel = _(issue.labels).includes(config.NOT_READY_ISSUE_LABEL); // eslint-disable-line lodash/chaining @@ -670,7 +676,7 @@ async function handleIssueUnAssignment(event, issue) { } if (dbIssue.assignee) { - const assigneeUserId = gitHelper.getUserIdByLogin(event, dbIssue.assignee); + const assigneeUserId = await gitHelper.getUserIdByLogin(event, dbIssue.assignee); if (!assigneeUserId) { // The assignement of this user was failed and broken. // We don't need to handle the unassignment. diff --git a/utils/git-helper.js b/utils/git-helper.js index cea9bea..dd953ac 100644 --- a/utils/git-helper.js +++ b/utils/git-helper.js @@ -149,7 +149,7 @@ class GitHelper { */ async getUserIdByLogin(event, assignee) { if (event.provider === 'github') { - return gitHubService.getUserIdByLogin(event.copilot, assignee); + return await gitHubService.getUserIdByLogin(event.copilot, assignee); } return gitlabService.getUserIdByLogin(event.copilot, assignee); }