diff --git a/config/default.js b/config/default.js index ac54b54..5dd571c 100644 --- a/config/default.js +++ b/config/default.js @@ -69,8 +69,6 @@ module.exports = { NEW_CHALLENGE_DURATION_IN_DAYS: process.env.NEW_CHALLENGE_DURATION_IN_DAYS || 5, TC_URL: process.env.TC_URL || 'https://www.topcoder-dev.com', GITLAB_API_BASE_URL: process.env.GITLAB_API_BASE_URL || 'https://gitlab.com', - AZURE_API_BASE_URL: process.env.AZURE_API_BASE_URL || 'https://app.vssps.visualstudio.com', - AZURE_DEVOPS_API_BASE_URL: process.env.AZURE_DEVOPS_API_BASE_URL || 'https://dev.azure.com', ISSUE_LABEL_PREFIX: process.env.ISSUE_LABEL_PREFIX || 'tcx_', PAID_ISSUE_LABEL: process.env.PAID_ISSUE_LABEL || 'tcx_Paid', FIX_ACCEPTED_ISSUE_LABEL: process.env.FIX_ACCEPTED_ISSUE_LABEL || 'tcx_FixAccepted', @@ -97,11 +95,6 @@ module.exports = { AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET, AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL, - AZURE_ACCESS_TOKEN_DEFAULT_EXPIRATION: 3600 * 24 * 14, - AZURE_REFRESH_TOKEN_BEFORE_EXPIRATION: 300, - AZURE_OWNER_CALLBACK_URL: '/api/v1/azure/owneruser/callback', - AZURE_CLIENT_SECRET: process.env.AZURE_CLIENT_SECRET, - // used as base to construct various URLs WEBSITE: process.env.WEBSITE || 'http://topcoderx.topcoder-dev.com', WEBSITE_SECURE: process.env.WEBSITE_SECURE || 'https://topcoderx.topcoder-dev.com', diff --git a/constants.js b/constants.js index 38bb5aa..a2d9d3c 100644 --- a/constants.js +++ b/constants.js @@ -14,8 +14,7 @@ // The user types const USER_TYPES = { GITHUB: 'github', - GITLAB: 'gitlab', - AZURE: 'azure' + GITLAB: 'gitlab' }; // The user roles diff --git a/models/UserMapping.js b/models/UserMapping.js index ce95639..1662597 100644 --- a/models/UserMapping.js +++ b/models/UserMapping.js @@ -25,10 +25,8 @@ const schema = new Schema({ }, githubUsername: String, gitlabUsername: String, - azureEmail: String, githubUserId: Number, - gitlabUserId: Number, - azureUserId: String + gitlabUserId: Number }); module.exports = schema; diff --git a/services/AzureService.js b/services/AzureService.js deleted file mode 100644 index e79a530..0000000 --- a/services/AzureService.js +++ /dev/null @@ -1,353 +0,0 @@ -/* - * Copyright (c) 2018 TopCoder, Inc. All rights reserved. - */ -'use strict'; - -/** - * This provides methods around azure api. - * @author TCSCODER - * @version 1.0 - */ - -const config = require('config'); -const _ = require('lodash'); -const Joi = require('joi'); -const superagent = require('superagent'); -const superagentPromise = require('superagent-promise'); -const logger = require('../utils/logger'); -const dbHelper = require('../utils/db-helper'); -const errors = require('../utils/errors'); -const helper = require('../utils/helper'); -const models = require('../models'); - -const request = superagentPromise(superagent, Promise); -const MS_PER_SECOND = 1000; - -const copilotUserSchema = Joi.object().keys({ - accessToken: Joi.string().required(), - userProviderId: Joi.number().required(), - topcoderUsername: Joi.string() -}).required(); - -/** - * creates the comments on azure issue - * @param {Object} copilot the copilot - * @param {String} repoFullName the organization/project-name - * @param {Number} workItemId the issue number - * @param {string} body the comment body text - */ -async function createComment(copilot, repoFullName, workItemId, body) { - Joi.attempt({copilot, repoFullName, workItemId, body}, createComment.schema); - try { - body = helper.prepareAutomatedComment(body, copilot); - await request - .post(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${workItemId}/comments?api-version=5.1-preview.3`) - .send({ - text: body - }) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json') - .end(); - } catch (err) { - throw errors.convertAzureError(err, 'Error occurred during creating comment on issue.'); - } - logger.debug(`Azure comment is added on issue with message: "${body}"`); -} - -createComment.schema = { - copilot: copilotUserSchema, - repoFullName: Joi.string().required(), - workItemId: Joi.number().positive().required(), - body: Joi.string().required() -}; - -/** - * updates the title of azure issue - * @param {Object} copilot the copilot - * @param {Number} repoFullName the project id - * @param {Number} issueId the issue number - * @param {string} title new title - */ -async function updateIssue(copilot, repoFullName, issueId, title) { - Joi.attempt({copilot, repoFullName, issueId, title}, updateIssue.schema); - try { - await request - .patch(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${issueId}?api-version=5.1`) - .send([{ - op: 'add', - path: '/fields/System.Title', - value: title - }]) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json-patch+json') - .end(); - } catch (err) { - throw errors.convertAzureError(err, 'Error occurred during updating issue.'); - } - logger.debug(`Azure issue title is updated for issue number ${issueId}`); -} - -updateIssue.schema = { - copilot: copilotUserSchema, - repoFullName: Joi.string().required(), - issueId: Joi.number().positive().required(), - title: Joi.string().required() -}; - -/** - * Assigns the issue to user login - * @param {Object} copilot the copilot - * @param {Number} repoFullName the project id - * @param {Number} issueId the issue number - * @param {Number} user the user id of assignee - */ -async function assignUser(copilot, repoFullName, issueId, user) { - Joi.attempt({copilot, repoFullName, issueId, user}, assignUser.schema); - try { - await request - .patch(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${issueId}?api-version=5.1`) - .send([{ - op: 'add', - path: '/fields/System.AssignedTo', - value: user - }]) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json-patch+json') - .end(); - } catch (err) { - throw errors.convertAzureError(err, 'Error occurred during update assignee.'); - } - logger.debug(`Azure issue with number ${issueId} is assigned to ${issueId}`); -} - -assignUser.schema = { - copilot: copilotUserSchema, - repoFullName: Joi.string().required(), - issueId: Joi.number().positive().required(), - user: Joi.string() -}; - -/** - * Removes an assignee from the issue - * @param {Object} copilot the copilot - * @param {Number} repoFullName the project id - * @param {Number} issueId the issue number - * @param {Number} userId the user id of assignee to remove - */ -async function removeAssign(copilot, repoFullName, issueId) { - Joi.attempt({copilot, repoFullName, issueId}, removeAssign.schema); - try { - await request - .patch(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${issueId}?api-version=5.1`) - .send([{ - op: 'add', - path: '/fields/System.AssignedTo', - value: '' - }]) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json-patch+json') - .end(); - } catch (err) { - throw errors.convertAzureError(err, 'Error occurred during remove assignee.'); - } - logger.debug(`Azure user is unassigned from issue number ${issueId}`); -} - -removeAssign.schema = assignUser.schema; - -/** - * Gets the user name by user id - * @param {Object} copilot the copilot - * @param {Number} userId the user id - * @returns {string} the username if found else null - */ -async function getUsernameById(copilot, userId) { - Joi.attempt({copilot, userId}, getUsernameById.schema); - const userProfile = await request - .get(`${config.AZURE_API_BASE_URL}/_apis/profile/profiles/${userId}?api-version=5.1`) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .end() - .then((res) => res.body); - return userProfile ? userProfile.emailAddress : null; -} - -getUsernameById.schema = { - copilot: copilotUserSchema, - userId: Joi.alternatives().try(Joi.string(), Joi.number()).required() -}; - -/** - * updates the azure issue as paid and fix accepted - * @param {Object} copilot the copilot - * @param {Number} repoFullName the project id - * @param {Number} issueId the issue number - * @param {Number} challengeId the challenge id - * @param {Array} existLabels the issue labels - * @param {String} winner the winner topcoder handle - * @param {Boolean} createCopilotPayments the option to create copilot payments or not - */ -async function markIssueAsPaid(copilot, repoFullName, issueId, challengeId, existLabels, winner, createCopilotPayments) { // eslint-disable-line max-params - Joi.attempt({copilot, repoFullName, issueId, challengeId}, markIssueAsPaid.schema); - const labels = _(existLabels).filter((i) => i !== config.FIX_ACCEPTED_ISSUE_LABEL) - .push(config.FIX_ACCEPTED_ISSUE_LABEL, config.PAID_ISSUE_LABEL).value(); - try { - await request - .patch(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${issueId}?api-version=5.1`) - .send([{ - op: 'add', - path: '/fields/System.Tags', - value: _.join(labels, '; ') - }]) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json-patch+json') - .end(); - - let commentMessage = '```\n'; - commentMessage += '*Payments Complete*\n'; - commentMessage += `Winner: ${winner}\n`; - if (createCopilotPayments) { - commentMessage += `Copilot: ${copilot.topcoderUsername}\n`; - } - commentMessage += '```\n'; - commentMessage += `Payment task has been updated: ${config.TC_OR_DETAIL_LINK}${challengeId}`; - const body = helper.prepareAutomatedComment(commentMessage, copilot); - await request - .post(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${issueId}/comments?api-version=5.1-preview.3`) - .send({ - text: body - }) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json') - .end(); - } catch (err) { - throw errors.convertAzureError(err, 'Error occurred during updating issue as paid.'); - } - logger.debug(`Azure issue is updated for as paid and fix accepted for ${issueId}`); -} - -markIssueAsPaid.schema = { - copilot: copilotUserSchema, - repoFullName: Joi.string().required(), - issueId: Joi.number().positive().required(), - challengeId: Joi.number().positive().required() -}; - -/** - * change the state of azure issue - * @param {Object} copilot the copilot - * @param {string} repoFullName the project id - * @param {Number} issueId the issue issue id - * @param {string} state new state - */ -async function changeState(copilot, repoFullName, issueId, state) { - Joi.attempt({copilot, repoFullName, issueId, state}, changeState.schema); - try { - await request - .patch(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${issueId}?api-version=5.1`) - .send([{ - op: 'add', - path: '/fields/System.State', - value: state - }]) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json-patch+json') - .end(); - } catch (err) { - throw errors.convertAzureError(err, 'Error occurred during updating status of issue.'); - } - logger.debug(`Azure issue state is updated to '${state}' for issue number ${issueId}`); -} - -changeState.schema = { - copilot: copilotUserSchema, - repoFullName: Joi.string().required(), - issueId: Joi.number().positive().required(), - state: Joi.string().required() -}; - -/** - * updates the azure issue with new labels - * @param {Object} copilot the copilot - * @param {string} repoFullName the project id - * @param {Number} issueId the issue issue id - * @param {Array} labels the labels - */ -async function addLabels(copilot, repoFullName, issueId, labels) { - Joi.attempt({copilot, repoFullName, issueId, labels}, addLabels.schema); - try { - // https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=5.1 - await request - .patch(`${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}/_apis/wit/workItems/${issueId}?api-version=5.1`) - .send([{ - op: 'add', - path: '/fields/System.Tags', - value: _.join(labels, '; ') - }]) - .set('Authorization', `Bearer ${copilot.accessToken}`) - .set('Content-Type', 'application/json-patch+json') - .end(); - } catch (err) { - throw errors.convertAzureError(err, 'Error occurred during adding label in issue.'); - } - logger.debug(`Azure issue is updated with new labels for ${issueId}`); -} - -addLabels.schema = { - copilot: copilotUserSchema, - repoFullName: Joi.string().required(), - issueId: Joi.number().required(), - labels: Joi.array().items(Joi.string()).required() -}; - -/** - * Refresh the owner user access token if needed - * @param {Object} azureOwner the azure owner - * @returns {Object} the user object - */ -async function refreshAzureUserAccessToken(azureOwner) { - const refreshTokenResult = await request - .post('https://app.vssps.visualstudio.com/oauth2/token') - .send({ - client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer', - client_assertion: encodeURIComponent(config.AZURE_CLIENT_SECRET), - assertion: encodeURIComponent(azureOwner.refreshToken), - grant_type: 'refresh_token', - redirect_uri: `${config.WEBSITE_SECURE}${config.AZURE_OWNER_CALLBACK_URL}` - }) - .set('Content-Type', 'application/x-www-form-urlencoded') - .end(); - // save user token data - const expiresIn = refreshTokenResult.body.expires_in || config.AZURE_ACCESS_TOKEN_DEFAULT_EXPIRATION; - return await dbHelper.update(models.User, azureOwner.id, { - accessToken: refreshTokenResult.body.access_token, - accessTokenExpiration: new Date(new Date().getTime() + expiresIn * MS_PER_SECOND), - refreshToken: refreshTokenResult.body.refresh_token - }); -} - -refreshAzureUserAccessToken.schema = Joi.object().keys({ - azureOwner: Joi.object().keys({ - id: Joi.string().required(), - accessTokenExpiration: Joi.date().required(), - refreshToken: Joi.string().required(), - role: Joi.string(), - userProviderId: Joi.number(), - type: Joi.string(), - accessToken: Joi.string(), - username: Joi.string() - }) -}); - -module.exports = { - createComment, - updateIssue, - assignUser, - removeAssign, - getUsernameById, - markIssueAsPaid, - changeState, - addLabels, - refreshAzureUserAccessToken -}; - -logger.buildService(module.exports); diff --git a/services/EventService.js b/services/EventService.js index 92975e9..4fa8c15 100644 --- a/services/EventService.js +++ b/services/EventService.js @@ -13,7 +13,6 @@ const _ = require('lodash'); const logger = require('../utils/logger'); const models = require('../models'); const dbHelper = require('../utils/db-helper'); -const azureService = require('./AzureService'); const gitHubService = require('./GithubService'); const gitlabService = require('./GitlabService'); @@ -29,8 +28,6 @@ async function reOpenIssue(event, issue) { await gitHubService.changeState(event.copilot, event.data.repository.full_name, issue.number, 'open'); } else if (event.provider === 'gitlab') { await gitlabService.changeState(event.copilot, event.data.repository.id, issue.number, 'reopen'); - } else if (event.provider === 'azure') { - await gitlabService.changeState(event.copilot, event.data.repository.full_name, issue.number, 'To Do'); } } @@ -96,8 +93,6 @@ async function handleEventGracefully(event, data, err) { await gitHubService.createComment(event.copilot, event.data.repository.full_name, data.number, comment); } else if (event.provider === 'gitlab') { await gitlabService.createComment(event.copilot, event.data.repository.id, data.number, comment); - } else if (event.provider === 'azure') { - await azureService.createComment(event.copilot, event.data.repository.full_name, data.number, comment); } if (event.event === 'issue.closed') { diff --git a/services/GithubService.js b/services/GithubService.js index 1c2d5e1..49ccf2e 100644 --- a/services/GithubService.js +++ b/services/GithubService.js @@ -255,7 +255,7 @@ async function markIssueAsPaid(copilot, repoFullName, number, challengeId, exist if (createCopilotPayments) { commentMessage += `Copilot: ${copilot.topcoderUsername}\n`; } - + const body = helper.prepareAutomatedComment(commentMessage, copilot); await github.issues.createComment({owner, repo, number, body}); } catch (err) { diff --git a/services/GitlabService.js b/services/GitlabService.js index 08780f9..f9bd29d 100644 --- a/services/GitlabService.js +++ b/services/GitlabService.js @@ -217,7 +217,7 @@ async function markIssueAsPaid(copilot, projectId, issueId, challengeId, existLa if (createCopilotPayments) { commentMessage += `Copilot: ${copilot.topcoderUsername}\n`; } - + const body = helper.prepareAutomatedComment(commentMessage, copilot); await gitlab.projects.issues.notes.create(projectId, issueId, {body}); } catch (err) { diff --git a/services/IssueService.js b/services/IssueService.js index 5e424e9..41f7195 100755 --- a/services/IssueService.js +++ b/services/IssueService.js @@ -599,8 +599,6 @@ async function handleIssueCreate(event, issue, forceAssign = false) { fullRepoUrl = `https://github.com/${event.data.repository.full_name}`; } else if (issue.provider === 'gitlab') { fullRepoUrl = `${config.GITLAB_API_BASE_URL}/${event.data.repository.full_name}`; - } else if (issue.provider === 'azure') { - fullRepoUrl = `${config.AZURE_DEVOPS_API_BASE_URL}/${event.data.repository.full_name}`; } logger.debugWithContext(`existing project was found with id ${projectId} for repository ${event.data.repository.full_name}`, event, issue); @@ -695,8 +693,7 @@ async function handleIssueUnAssignment(event, issue) { } if (dbIssue.assignee) { - const assigneeUserId = event.provider === 'azure' ? dbIssue.assignee : - await 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. @@ -864,7 +861,7 @@ async function process(event) { const copilot = await userService.getRepositoryCopilotOrOwner(event.provider, event.data.repository.full_name); event.copilot = copilot; - // Some provider (azure) has non numeric repo id. we need to convert it to number by hashing it. + // Some provider has non numeric repo id. we need to convert it to number by hashing it. if (_.isString(issue.repositoryId)) { issue.repositoryIdStr = issue.repositoryId; issue.repositoryId = helper.hashCode(issue.repositoryId); @@ -897,7 +894,7 @@ async function process(event) { process.schema = Joi.object().keys({ event: Joi.string().valid('issue.created', 'issue.updated', 'issue.closed', 'comment.created', 'comment.updated', 'issue.assigned', 'issue.labelUpdated', 'issue.unassigned', 'issue.recreated').required(), - provider: Joi.string().valid('github', 'gitlab', 'azure').required(), + provider: Joi.string().valid('github', 'gitlab').required(), data: Joi.object().keys({ issue: Joi.object().keys({ number: Joi.number().required(), diff --git a/services/UserService.js b/services/UserService.js index b6bf357..5483d56 100755 --- a/services/UserService.js +++ b/services/UserService.js @@ -16,7 +16,6 @@ const _ = require('lodash'); const logger = require('../utils/logger'); const dbHelper = require('../utils/db-helper'); const models = require('../models'); -const azureService = require('./AzureService'); /** * gets the tc handle for given git user id from a mapping captured by Topcoder x tool @@ -32,16 +31,12 @@ async function getTCUserName(provider, gitUser) { criteria.githubUserId = gitUser; } else if (provider === 'gitlab') { criteria.gitlabUserId = gitUser; - } else if (provider === 'azure') { - criteria.azureUserId = gitUser; } } else if (_.isString(gitUser) || v.isEmail(gitUser)) { if (provider === 'github') { criteria.githubUsername = gitUser; } else if (provider === 'gitlab') { criteria.gitlabUsername = gitUser; - } else if (provider === 'azure') { - criteria.azureEmail = gitUser; } } if (_.isEmpty(criteria)) { @@ -51,7 +46,7 @@ async function getTCUserName(provider, gitUser) { } getTCUserName.schema = { - provider: Joi.string().valid('github', 'gitlab', 'azure').required(), + provider: Joi.string().valid('github', 'gitlab').required(), gitUser: Joi.any().required() }; @@ -69,8 +64,6 @@ async function getRepositoryCopilotOrOwner(provider, repoFullName) { fullRepoUrl = `https://github.com/${repoFullName}`; } else if (provider === 'gitlab') { fullRepoUrl = `${config.GITLAB_API_BASE_URL}/${repoFullName}`; - } else if (provider === 'azure') { - fullRepoUrl = `${config.AZURE_DEVOPS_API_BASE_URL}/${repoFullName}`; } const project = await dbHelper.scanOne(models.Project, { repoUrl: fullRepoUrl @@ -91,20 +84,15 @@ async function getRepositoryCopilotOrOwner(provider, repoFullName) { if (!userMapping || (provider === 'github' && !userMapping.githubUserId) || - (provider === 'gitlab' && !userMapping.gitlabUserId) || - (provider === 'azure' && !userMapping.azureUserId)) { + (provider === 'gitlab' && !userMapping.gitlabUserId)) { throw new Error(`Couldn't find githost username for '${provider}' for this repository '${repoFullName}'.`); } - let user = await dbHelper.scanOne(models.User, { + const user = await dbHelper.scanOne(models.User, { username: provider === 'github' ? userMapping.githubUsername : // eslint-disable-line no-nested-ternary - provider === 'gitlab' ? userMapping.gitlabUsername : userMapping.azureEmail, + userMapping.gitlabUsername, type: provider }); - if (provider === 'azure') { - user = await azureService.refreshAzureUserAccessToken(user); - } - if (!user && !hasCopilot) { // throw no copilot is configured throw new Error(`No owner is configured for the this repository: ${provider}`); @@ -121,7 +109,7 @@ async function getRepositoryCopilotOrOwner(provider, repoFullName) { } getRepositoryCopilotOrOwner.schema = { - provider: Joi.string().valid('github', 'gitlab', 'azure').required(), + provider: Joi.string().valid('github', 'gitlab').required(), repoFullName: Joi.string().required() }; diff --git a/utils/errors.js b/utils/errors.js index 9064c7c..a27193e 100644 --- a/utils/errors.js +++ b/utils/errors.js @@ -66,26 +66,6 @@ errors.convertGitLabError = function convertGitLabError(err, message) { return apiError; }; -/** - * Convert azure api error. - * @param {Error} err the azure api error - * @param {String} message the error message - * @returns {Error} converted error - */ -errors.convertAzureError = function convertAzureError(err, message) { - let resMsg = `${message}. ${err.message}.`; - const detail = _.get(err, 'response.body.message'); - if (detail) { - resMsg += ` Detail: ${detail}`; - } - const apiError = new ProcessorError( - err.status || _.get(err, 'response.status', constants.SERVICE_ERROR_STATUS), - resMsg, - 'azure' - ); - return apiError; -}; - /** * Convert topcoder api error. * @param {Error} err the topcoder api error diff --git a/utils/git-helper.js b/utils/git-helper.js index c9fab52..a13ba4f 100644 --- a/utils/git-helper.js +++ b/utils/git-helper.js @@ -14,7 +14,6 @@ const config = require('config'); const gitHubService = require('../services/GithubService'); const gitlabService = require('../services/GitlabService'); -const azureService = require('../services/AzureService'); class GitHelper { /** @@ -28,8 +27,6 @@ class GitHelper { await gitHubService.createComment(event.copilot, event.data.repository.full_name, issueNumber, comment); } else if (event.provider === 'gitlab') { await gitlabService.createComment(event.copilot, event.data.repository.id, issueNumber, comment); - } else if (event.provider === 'azure') { - await azureService.createComment(event.copilot, event.data.repository.full_name, issueNumber, comment); } } @@ -44,8 +41,6 @@ class GitHelper { await gitHubService.addLabels(event.copilot, event.data.repository.full_name, issueNumber, labels); } else if (event.provider === 'gitlab') { await gitlabService.addLabels(event.copilot, event.data.repository.id, issueNumber, labels); - } else if (event.provider === 'azure') { - await azureService.addLabels(event.copilot, event.data.repository.full_name, issueNumber, labels); } } @@ -59,8 +54,6 @@ class GitHelper { await gitHubService.changeState(event.copilot, event.data.repository.full_name, issue.number, 'open'); } else if (event.provider === 'gitlab') { await gitlabService.changeState(event.copilot, event.data.repository.id, issue.number, 'reopen'); - } else if (event.provider === 'azure') { - await azureService.changeState(event.copilot, event.data.repository.full_name, issue.number, 'To Do'); } } @@ -75,8 +68,6 @@ class GitHelper { return await gitHubService.getUsernameById(event.copilot, assigneeUserId); } else if (event.provider === 'gitlab') { return await gitlabService.getUsernameById(event.copilot, assigneeUserId); - } else if (event.provider === 'azure') { - return await azureService.getUsernameById(event.copilot, assigneeUserId); } return null; } @@ -93,8 +84,6 @@ class GitHelper { await gitHubService.removeAssign(event.copilot, event.data.repository.full_name, issueNumber, assigneeUsername); } else if (event.provider === 'gitlab') { await gitlabService.removeAssign(event.copilot, event.data.repository.id, issueNumber, assigneeUserId); - } else if (event.provider === 'azure') { - await azureService.removeAssign(event.copilot, event.data.repository.full_name, issueNumber); } } @@ -109,8 +98,6 @@ class GitHelper { await gitHubService.updateIssue(event.copilot, event.data.repository.full_name, issueNumber, newTitle); } else if (event.provider === 'gitlab') { await gitlabService.updateIssue(event.copilot, event.data.repository.id, issueNumber, newTitle); - } else if (event.provider === 'azure') { - await azureService.updateIssue(event.copilot, event.data.repository.full_name, issueNumber, newTitle); } } @@ -126,8 +113,6 @@ class GitHelper { } else if (event.provider === 'gitlab') { const userId = await gitlabService.getUserIdByLogin(event.copilot, assignedUser); await gitlabService.assignUser(event.copilot, event.data.repository.id, issueNumber, userId); - } else if (event.provider === 'azure') { - await azureService.assignUser(event.copilot, event.data.repository.full_name, issueNumber, assignedUser); } } @@ -159,15 +144,6 @@ class GitHelper { existLabels, winner, createCopilotPayments); - } else if (event.provider === 'azure') { - await azureService.markIssueAsPaid( - event.copilot, - event.data.repository.full_name, - issueNumber, - challengeId, - existLabels, - winner, - createCopilotPayments); } } @@ -181,8 +157,6 @@ class GitHelper { return `https://github.com/${event.data.repository.full_name}`; } else if (event.provider === 'gitlab') { return `${config.GITLAB_API_BASE_URL}/${event.data.repository.full_name}`; - } else if (event.provider === 'azure') { - return `${config.AZURE_DEVOPS_API_BASE_URL}/${event.data.repository.full_name}`; } return null; } @@ -198,8 +172,6 @@ class GitHelper { return await gitHubService.getUserIdByLogin(event.copilot, assignee); } else if (event.provider === 'gitlab') { return gitlabService.getUserIdByLogin(event.copilot, assignee); - } else if (event.provider === 'azure') { - return azureService.getUserIdByLogin(event.copilot, assignee); } return null; }