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

Comment for assigning without open for pickup label. Restore m2m toke… #50

Merged
merged 1 commit into from
Apr 26, 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: 2 additions & 0 deletions services/IssueService.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ async function handleIssueAssignment(event, issue, force = false) {
const contestUrl = getUrlForChallengeId(dbIssue.challengeId);
const comment = `Contest ${contestUrl} has been updated - ${userMapping.topcoderUsername} has been unassigned.`;
await rollbackAssignee(event, assigneeUserId, issue, false, comment);
const additionalComment = `${userMapping.topcoderUsername} has been unassigned because this ticket doesn't have the ${config.OPEN_FOR_PICKUP_ISSUE_LABEL} label.`; // eslint-disable-line max-len
await gitHelper.createComment(event, issue.number, additionalComment);
} else {
const comment = `This ticket isn't quite ready to be worked on yet. Please wait until it has the ${config.OPEN_FOR_PICKUP_ISSUE_LABEL} label`;
await rollbackAssignee(event, assigneeUserId, issue, false, comment);
Expand Down
30 changes: 15 additions & 15 deletions utils/topcoder-api-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const challengesApiInstance = new topcoderApiChallenges.DefaultApi();
* @returns {String} the access token issued by Topcoder
* @private
*/
async function getAccessToken() {
async function getAccessToken() { // eslint-disable-line no-unused-vars
// Check the cached access token
if (cachedAccessToken) {
const decoded = jwtDecode(cachedAccessToken);
Expand Down Expand Up @@ -115,7 +115,7 @@ async function getM2Mtoken() {
* @returns {Number} the created project id
*/
async function createProject(projectName) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
// eslint-disable-next-line new-cap
const projectBody = new topcoderApiProjects.ProjectRequestBody.constructFromObject({
projectName
Expand Down Expand Up @@ -147,7 +147,7 @@ async function createProject(projectName) {
* @returns {Number} the created challenge id
*/
async function createChallenge(challenge) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
const start = new Date();
const startTime = moment(start).toISOString();
const end = moment(start).add(config.NEW_CHALLENGE_DURATION_IN_DAYS, 'days').toISOString();
Expand Down Expand Up @@ -188,7 +188,7 @@ async function createChallenge(challenge) {
* @param {Object} challenge the challenge to update
*/
async function updateChallenge(id, challenge) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
logger.debug(`Updating challenge ${id} with ${circularJSON.stringify(challenge)}`);
// eslint-disable-next-line new-cap
const challengeBody = new topcoderApiChallenges.UpdateChallengeBodyParam.constructFromObject({
Expand Down Expand Up @@ -226,7 +226,7 @@ async function updateChallenge(id, challenge) {
* @param {Number} id the challenge id
*/
async function activateChallenge(id) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
logger.debug(`Activating challenge ${id}`);
try {
const response = await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -266,7 +266,7 @@ async function getChallengeById(id) {
if (!_.isNumber(id)) {
throw new Error('The challenge id must valid number');
}
const apiKey = await getAccessToken();
const apiKey = await getM2Mtoken();
logger.debug('Getting topcoder challenge details');
try {
const response = await axios.get(`${challengesClient.basePath}/challenges/${id}`, {
Expand Down Expand Up @@ -297,7 +297,7 @@ async function getChallengeById(id) {
* @param {Number} winnerId the winner id
*/
async function closeChallenge(id, winnerId) {
const apiKey = await getAccessToken();
const apiKey = await getM2Mtoken();
logger.debug(`Closing challenge ${id}`);
try {
const basePath = challengesClient.basePath;
Expand Down Expand Up @@ -328,7 +328,7 @@ async function closeChallenge(id, winnerId) {
* @returns {Number} the billing account id
*/
async function getProjectBillingAccountId(id) {
const apiKey = await getAccessToken();
const apiKey = await getM2Mtoken();
logger.debug(`Getting project billing detail ${id}`);
try {
const response = await axios.get(`${projectsClient.basePath}/direct/projects/${id}`, {
Expand Down Expand Up @@ -360,7 +360,7 @@ async function getProjectBillingAccountId(id) {
* @returns {Number} the user id
*/
async function getTopcoderMemberId(handle) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
try {
const response = await axios.get(`${projectsClient.basePath}/members/${handle}`);
const statusCode = response ? response.status : null;
Expand All @@ -379,7 +379,7 @@ async function getTopcoderMemberId(handle) {
* @param {Object} resource the resource resource to add
*/
async function addResourceToChallenge(id, resource) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
logger.debug(`adding resource to challenge ${id}`);
try {
const response = await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -420,7 +420,7 @@ async function getResourcesFromChallenge(id) {
if (!_.isNumber(id)) {
throw new Error('The challenge id must valid number');
}
const apiKey = await getAccessToken();
const apiKey = await getM2Mtoken();
logger.debug(`fetch resource from challenge ${id}`);
try {
const response = await axios.get(`${challengesClient.basePath}/challenges/${id}/resources`, {
Expand Down Expand Up @@ -465,7 +465,7 @@ async function roleAlreadySet(id, role) {
* @param {Object} resource the resource resource to remove
*/
async function unregisterUserFromChallenge(id) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
logger.debug(`removing resource from challenge ${id}`);
try {
const response = await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -502,7 +502,7 @@ async function unregisterUserFromChallenge(id) {
* @param {Number} id the challenge id
*/
async function cancelPrivateContent(id) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
logger.debug(`Cancelling challenge ${id}`);
try {
const response = await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -550,7 +550,7 @@ async function assignUserAsRegistrant(topcoderUserId, challengeId) {
* @param {Object} resource the resource resource to remove
*/
async function removeResourceToChallenge(id, resource) {
bearer.apiKey = await getAccessToken();
bearer.apiKey = await getM2Mtoken();
logger.debug(`removing resource from challenge ${id}`);
try {
const response = await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -580,7 +580,7 @@ async function removeResourceToChallenge(id, resource) {
* @returns {Array} the resources of challenge
*/
async function getChallengeResources(id) {
const apiKey = await getAccessToken();
const apiKey = await getM2Mtoken();
logger.debug(`getting resource from challenge ${id}`);
try {
const response = await axios.get(`${challengesClient.basePath}/challenges/${id}/resources`, {
Expand Down