Skip to content

Commit 06170bb

Browse files
author
James Cori
committed
Removing the v5 check
1 parent b700db4 commit 06170bb

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ The following parameters can be set in config files or in env variables:
6262
- ES.ES_REFRESH: Elasticsearch refresh method. Default to string `true`(i.e. refresh immediately)
6363
- FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes
6464
- RESOURCES_API_URL: TC resources API base URL
65+
- V3_PROJECTS_API_URL: TC direct projects API base URL
6566
- GROUPS_API_URL: TC groups API base URL
6667
- PROJECTS_API_URL: TC projects API base URL
6768
- TERMS_API_URL: TC Terms API Base URL

config/default.js

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module.exports = {
5454
GROUPS_API_URL: process.env.GROUPS_API_URL || 'http://localhost:4000/v5/groups',
5555
PROJECTS_API_URL: process.env.PROJECTS_API_URL || 'http://localhost:4000/v5/projects',
5656
TERMS_API_URL: process.env.TERMS_API_URL || 'http://localhost:4000/v5/terms',
57+
V3_PROJECTS_API_URL: process.env.V3_PROJECTS_API_URL || 'http://localhost:4000/v3/direct/projects',
5758
// copilot resource role ids allowed to upload attachment
5859
COPILOT_RESOURCE_ROLE_IDS: process.env.COPILOT_RESOURCE_ROLE_IDS
5960
? process.env.COPILOT_RESOURCE_ROLE_IDS.split(',') : ['10ba038e-48da-487b-96e8-8d3b99b6d18b'],

src/common/helper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,10 @@ async function getProjectDefaultTerms (projectId) {
759759
*/
760760
async function getProjectBillingAccount (projectId) {
761761
const token = await getM2MToken()
762-
const projectUrl = `${config.PROJECTS_API_URL}/${projectId}`
762+
const projectUrl = `${config.V3_PROJECTS_API_URL}/${projectId}`
763763
try {
764764
const res = await axios.get(projectUrl, { headers: { Authorization: `Bearer ${token}` } })
765-
return _.get(res, 'data.billingAccountId', null)
765+
return _.get(res, 'data.result.content.billingAccountIds[0]', null)
766766
} catch (err) {
767767
if (_.get(err, 'response.status') === HttpStatus.NOT_FOUND) {
768768
throw new errors.BadRequestError(`Project with id: ${projectId} doesn't exist`)

src/services/ChallengeService.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ async function update (currentUser, challengeId, data, isFull) {
12091209
if (!_.get(challenge, 'legacy.pureV5Task') && _.isUndefined(_.get(challenge, 'legacy.directProjectId'))) {
12101210
throw new errors.BadRequestError('You cannot activate the challenge as it has not been created on legacy yet. Please try again later or contact support.')
12111211
}
1212-
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'projectId'))
1212+
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'legacy.directProjectId'))
12131213
// if activating a challenge, the challenge must have a billing account id
12141214
if ((!billingAccountId || billingAccountId === null) &&
12151215
challenge.status === constants.challengeStatuses.Draft) {
@@ -1220,7 +1220,7 @@ async function update (currentUser, challengeId, data, isFull) {
12201220
if (challenge.status !== constants.challengeStatuses.Active) {
12211221
throw new errors.BadRequestError('You cannot mark a Draft challenge as Completed')
12221222
}
1223-
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'projectId'))
1223+
billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'legacy.directProjectId'))
12241224
}
12251225
}
12261226

0 commit comments

Comments
 (0)