Skip to content

Commit 3405ff2

Browse files
Merge pull request #472 from topcoder-platform/develop
PROD_Release: Resolve duplicate payment issue
2 parents 6e927d5 + 8aac674 commit 3405ff2

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/helper.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -764,16 +764,21 @@ function getBusApiClient () {
764764
* Post bus event.
765765
* @param {String} topic the event topic
766766
* @param {Object} payload the event payload
767+
* @param {Object} options the extra options to the message
767768
*/
768-
async function postBusEvent (topic, payload) {
769+
async function postBusEvent (topic, payload, options = {}) {
769770
const client = getBusApiClient()
770-
await client.postEvent({
771+
const message = {
771772
topic,
772773
originator: constants.EVENT_ORIGINATOR,
773774
timestamp: new Date().toISOString(),
774775
'mime-type': constants.EVENT_MIME_TYPE,
775776
payload
776-
})
777+
}
778+
if (options.key) {
779+
message.key = options.key
780+
}
781+
await client.postEvent(message)
777782
}
778783

779784
/**

src/services/ChallengeService.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1951,7 +1951,11 @@ async function update (currentUser, challengeId, data, isFull) {
19511951

19521952
// post bus event
19531953
logger.debug(`Post Bus Event: ${constants.Topics.ChallengeUpdated} ${JSON.stringify(challenge)}`)
1954-
await helper.postBusEvent(constants.Topics.ChallengeUpdated, challenge)
1954+
const options = {}
1955+
if (challenge.status == 'Completed') {
1956+
options.key = `${challenge.id}:${challenge.status}`
1957+
}
1958+
await helper.postBusEvent(constants.Topics.ChallengeUpdated, challenge, options)
19551959
if (phasesHaveBeenModified === true && _.get(challenge, 'legacy.useSchedulingAPI')) {
19561960
await helper.postBusEvent(config.SCHEDULING_TOPIC, { id: challengeId })
19571961
}

0 commit comments

Comments
 (0)