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

Commit 1470466

Browse files
authored
Merge pull request #50 from afrisalyp/develop
Comment for assigning without open for pickup label. Restore m2m toke…
2 parents e229776 + 7f57230 commit 1470466

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

services/IssueService.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ async function handleIssueAssignment(event, issue, force = false) {
237237
const contestUrl = getUrlForChallengeId(dbIssue.challengeId);
238238
const comment = `Contest ${contestUrl} has been updated - ${userMapping.topcoderUsername} has been unassigned.`;
239239
await rollbackAssignee(event, assigneeUserId, issue, false, comment);
240+
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
241+
await gitHelper.createComment(event, issue.number, additionalComment);
240242
} else {
241243
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`;
242244
await rollbackAssignee(event, assigneeUserId, issue, false, comment);

utils/topcoder-api-helper.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const challengesApiInstance = new topcoderApiChallenges.DefaultApi();
6060
* @returns {String} the access token issued by Topcoder
6161
* @private
6262
*/
63-
async function getAccessToken() {
63+
async function getAccessToken() { // eslint-disable-line no-unused-vars
6464
// Check the cached access token
6565
if (cachedAccessToken) {
6666
const decoded = jwtDecode(cachedAccessToken);
@@ -115,7 +115,7 @@ async function getM2Mtoken() {
115115
* @returns {Number} the created project id
116116
*/
117117
async function createProject(projectName) {
118-
bearer.apiKey = await getAccessToken();
118+
bearer.apiKey = await getM2Mtoken();
119119
// eslint-disable-next-line new-cap
120120
const projectBody = new topcoderApiProjects.ProjectRequestBody.constructFromObject({
121121
projectName
@@ -147,7 +147,7 @@ async function createProject(projectName) {
147147
* @returns {Number} the created challenge id
148148
*/
149149
async function createChallenge(challenge) {
150-
bearer.apiKey = await getAccessToken();
150+
bearer.apiKey = await getM2Mtoken();
151151
const start = new Date();
152152
const startTime = moment(start).toISOString();
153153
const end = moment(start).add(config.NEW_CHALLENGE_DURATION_IN_DAYS, 'days').toISOString();
@@ -188,7 +188,7 @@ async function createChallenge(challenge) {
188188
* @param {Object} challenge the challenge to update
189189
*/
190190
async function updateChallenge(id, challenge) {
191-
bearer.apiKey = await getAccessToken();
191+
bearer.apiKey = await getM2Mtoken();
192192
logger.debug(`Updating challenge ${id} with ${circularJSON.stringify(challenge)}`);
193193
// eslint-disable-next-line new-cap
194194
const challengeBody = new topcoderApiChallenges.UpdateChallengeBodyParam.constructFromObject({
@@ -226,7 +226,7 @@ async function updateChallenge(id, challenge) {
226226
* @param {Number} id the challenge id
227227
*/
228228
async function activateChallenge(id) {
229-
bearer.apiKey = await getAccessToken();
229+
bearer.apiKey = await getM2Mtoken();
230230
logger.debug(`Activating challenge ${id}`);
231231
try {
232232
const response = await new Promise((resolve, reject) => {
@@ -266,7 +266,7 @@ async function getChallengeById(id) {
266266
if (!_.isNumber(id)) {
267267
throw new Error('The challenge id must valid number');
268268
}
269-
const apiKey = await getAccessToken();
269+
const apiKey = await getM2Mtoken();
270270
logger.debug('Getting topcoder challenge details');
271271
try {
272272
const response = await axios.get(`${challengesClient.basePath}/challenges/${id}`, {
@@ -297,7 +297,7 @@ async function getChallengeById(id) {
297297
* @param {Number} winnerId the winner id
298298
*/
299299
async function closeChallenge(id, winnerId) {
300-
const apiKey = await getAccessToken();
300+
const apiKey = await getM2Mtoken();
301301
logger.debug(`Closing challenge ${id}`);
302302
try {
303303
const basePath = challengesClient.basePath;
@@ -328,7 +328,7 @@ async function closeChallenge(id, winnerId) {
328328
* @returns {Number} the billing account id
329329
*/
330330
async function getProjectBillingAccountId(id) {
331-
const apiKey = await getAccessToken();
331+
const apiKey = await getM2Mtoken();
332332
logger.debug(`Getting project billing detail ${id}`);
333333
try {
334334
const response = await axios.get(`${projectsClient.basePath}/direct/projects/${id}`, {
@@ -360,7 +360,7 @@ async function getProjectBillingAccountId(id) {
360360
* @returns {Number} the user id
361361
*/
362362
async function getTopcoderMemberId(handle) {
363-
bearer.apiKey = await getAccessToken();
363+
bearer.apiKey = await getM2Mtoken();
364364
try {
365365
const response = await axios.get(`${projectsClient.basePath}/members/${handle}`);
366366
const statusCode = response ? response.status : null;
@@ -379,7 +379,7 @@ async function getTopcoderMemberId(handle) {
379379
* @param {Object} resource the resource resource to add
380380
*/
381381
async function addResourceToChallenge(id, resource) {
382-
bearer.apiKey = await getAccessToken();
382+
bearer.apiKey = await getM2Mtoken();
383383
logger.debug(`adding resource to challenge ${id}`);
384384
try {
385385
const response = await new Promise((resolve, reject) => {
@@ -420,7 +420,7 @@ async function getResourcesFromChallenge(id) {
420420
if (!_.isNumber(id)) {
421421
throw new Error('The challenge id must valid number');
422422
}
423-
const apiKey = await getAccessToken();
423+
const apiKey = await getM2Mtoken();
424424
logger.debug(`fetch resource from challenge ${id}`);
425425
try {
426426
const response = await axios.get(`${challengesClient.basePath}/challenges/${id}/resources`, {
@@ -465,7 +465,7 @@ async function roleAlreadySet(id, role) {
465465
* @param {Object} resource the resource resource to remove
466466
*/
467467
async function unregisterUserFromChallenge(id) {
468-
bearer.apiKey = await getAccessToken();
468+
bearer.apiKey = await getM2Mtoken();
469469
logger.debug(`removing resource from challenge ${id}`);
470470
try {
471471
const response = await new Promise((resolve, reject) => {
@@ -502,7 +502,7 @@ async function unregisterUserFromChallenge(id) {
502502
* @param {Number} id the challenge id
503503
*/
504504
async function cancelPrivateContent(id) {
505-
bearer.apiKey = await getAccessToken();
505+
bearer.apiKey = await getM2Mtoken();
506506
logger.debug(`Cancelling challenge ${id}`);
507507
try {
508508
const response = await new Promise((resolve, reject) => {
@@ -550,7 +550,7 @@ async function assignUserAsRegistrant(topcoderUserId, challengeId) {
550550
* @param {Object} resource the resource resource to remove
551551
*/
552552
async function removeResourceToChallenge(id, resource) {
553-
bearer.apiKey = await getAccessToken();
553+
bearer.apiKey = await getM2Mtoken();
554554
logger.debug(`removing resource from challenge ${id}`);
555555
try {
556556
const response = await new Promise((resolve, reject) => {
@@ -580,7 +580,7 @@ async function removeResourceToChallenge(id, resource) {
580580
* @returns {Array} the resources of challenge
581581
*/
582582
async function getChallengeResources(id) {
583-
const apiKey = await getAccessToken();
583+
const apiKey = await getM2Mtoken();
584584
logger.debug(`getting resource from challenge ${id}`);
585585
try {
586586
const response = await axios.get(`${challengesClient.basePath}/challenges/${id}/resources`, {

0 commit comments

Comments
 (0)