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

Commit 563c520

Browse files
trigger notifications after updating a challenge
1 parent 607cad5 commit 563c520

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/services/challengeService.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ async function updateChallenge (challenge) {
9393
}
9494
}
9595
})
96+
await triggerNotification(challenge.id)
9697
return challenge.id
9798
} catch (e) {
9899
throw Error(`updateChallenge Failed ${e}`)
@@ -883,6 +884,20 @@ async function convertGroupIdsToV5UUIDs (oldIds) {
883884
return groups
884885
}
885886

887+
async function triggerNotification (v5Id) {
888+
const token = await getM2MToken()
889+
const url = `${config.CHALLENGE_API_URL}/${v5Id}/notifications`
890+
// logger.debug(`Get Challenge from V5 URL ${url}`)
891+
let res = null
892+
try {
893+
res = await axios.post(url, {}, { headers: { Authorization: `Bearer ${token}` } })
894+
} catch (e) {
895+
logger.error(`Axios Error: ${JSON.stringify(e)}`)
896+
}
897+
// console.log(res.data)
898+
return res.data || null
899+
}
900+
886901
async function getChallengeFromV5API (legacyId) {
887902
const token = await getM2MToken()
888903
const url = `${config.CHALLENGE_API_URL}?legacyId=${legacyId}&perPage=1&page=1`

0 commit comments

Comments
 (0)