Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Handle assignment changes. #42

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/GithubService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
8 changes: 7 additions & 1 deletion services/IssueService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion utils/git-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down