Skip to content

Commit 6d4a177

Browse files
authored
Merge pull request #336 from xxcxy/feature/topic-bus-key
Include addition param key to Postevent method #329
2 parents 7c80214 + da72528 commit 6d4a177

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/common/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,8 @@ async function postEvent (topic, payload, options = {}) {
953953
payload
954954
}
955955
if (options.key) {
956-
message.key = options.key
957-
}
956+
message.key = options.key
957+
}
958958
await client.postEvent(message)
959959
await eventDispatcher.handleEvent(topic, { value: payload, options })
960960
}

src/services/WorkPeriodPaymentService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function _createSingleWorkPeriodPaymentWithWorkPeriodAndResourceBooking (w
9696
}
9797
}
9898

99-
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_CREATE_TOPIC, created.toJSON())
99+
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_CREATE_TOPIC, created.toJSON(), { key: `workPeriodPayment.billingAccountId:${workPeriodPayment.billingAccountId}` })
100100
return created.dataValues
101101
}
102102

@@ -234,7 +234,7 @@ async function updateWorkPeriodPayment (currentUser, id, data) {
234234
}
235235
}
236236

237-
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue })
237+
await helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue, key: `workPeriodPayment.billingAccountId:${updated.billingAccountId}` })
238238
return updated.dataValues
239239
}
240240

src/services/WorkPeriodService.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ async function createWorkPeriod (currentUser, workPeriod) {
235235
}
236236
}
237237

238-
await helper.postEvent(config.TAAS_WORK_PERIOD_CREATE_TOPIC, created.toJSON(),{"key":workPeriod.resourceBookingId})
238+
await helper.postEvent(config.TAAS_WORK_PERIOD_CREATE_TOPIC, created.toJSON(), { key: `resourceBooking.id:${workPeriod.resourceBookingId}` })
239239
return created.dataValues
240240
}
241241

@@ -289,8 +289,8 @@ async function updateWorkPeriod (currentUser, id, data) {
289289
}
290290
}
291291

292-
//await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue })
293-
await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), {oldValue: oldValue, "key":data.resourceBookingId})
292+
// await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue })
293+
await helper.postEvent(config.TAAS_WORK_PERIOD_UPDATE_TOPIC, updated.toJSON(), { oldValue: oldValue, key: `resourceBooking.id:${data.resourceBookingId}` })
294294
return updated.dataValues
295295
}
296296

@@ -364,9 +364,9 @@ async function deleteWorkPeriod (currentUser, id) {
364364
workPeriodId: id
365365
}
366366
})
367-
await Promise.all(workPeriod.payments.map(({ id }) => helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_DELETE_TOPIC, { id })))
367+
await Promise.all(workPeriod.payments.map(({ id, billingAccountId }) => helper.postEvent(config.TAAS_WORK_PERIOD_PAYMENT_DELETE_TOPIC, { id }, { key: `workPeriodPayment.billingAccountId:${billingAccountId}` })))
368368
await workPeriod.destroy()
369-
await helper.postEvent(config.TAAS_WORK_PERIOD_DELETE_TOPIC, { id })
369+
await helper.postEvent(config.TAAS_WORK_PERIOD_DELETE_TOPIC, { id }, { key: `resourceBooking.id:${workPeriod.resourceBookingId}` })
370370
}
371371

372372
deleteWorkPeriod.schema = Joi.object().keys({

0 commit comments

Comments
 (0)