feat: restructure events payload (#8143)
* refactor: restructure events payload Breaking change: This PR changes the event payload accepted by the event listeners * refactor: fix failing tests and implement feedback * add integration tests * fix timeout --------- Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
co-authored by
Adrien de Peretti
parent
5813216c88
commit
f579f0b3be
@@ -44,8 +44,7 @@ const configAsMap = handlerConfig.reduce(
|
||||
)
|
||||
|
||||
export default async function configurableNotifications({
|
||||
data,
|
||||
eventName,
|
||||
event,
|
||||
container,
|
||||
}: SubscriberArgs<any>) {
|
||||
const logger = container.resolve(ContainerRegistrationKeys.LOGGER)
|
||||
@@ -53,8 +52,8 @@ export default async function configurableNotifications({
|
||||
ModuleRegistrationName.NOTIFICATION
|
||||
)
|
||||
|
||||
const handlers = configAsMap[eventName] ?? []
|
||||
const payload = data.data
|
||||
const handlers = configAsMap[event.name] ?? []
|
||||
const payload = event.data
|
||||
|
||||
await promiseAll(
|
||||
handlers.map(async (handler) => {
|
||||
@@ -75,7 +74,7 @@ export default async function configurableNotifications({
|
||||
await notificationService.createNotifications(notificationData)
|
||||
} catch (err) {
|
||||
logger.error(
|
||||
`Failed to send notification for ${eventName}`,
|
||||
`Failed to send notification for ${event.name}`,
|
||||
err.message
|
||||
)
|
||||
}
|
||||
|
||||
@@ -8,14 +8,14 @@ type SerializedBuffer = {
|
||||
}
|
||||
|
||||
export default async function paymentWebhookhandler({
|
||||
data,
|
||||
event,
|
||||
container,
|
||||
}: SubscriberArgs<ProviderWebhookPayload>) {
|
||||
const paymentService: IPaymentModuleService = container.resolve(
|
||||
ModuleRegistrationName.PAYMENT
|
||||
)
|
||||
|
||||
const input = "data" in data ? data.data : data
|
||||
const input = event.data
|
||||
|
||||
if (
|
||||
(input.payload.rawData as unknown as SerializedBuffer).type === "Buffer"
|
||||
|
||||
Reference in New Issue
Block a user