Skip to content

Commit

Permalink
Remove promise.all
Browse files Browse the repository at this point in the history
  • Loading branch information
amateima committed Nov 25, 2024
1 parent 5d32c0b commit 5503792
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/webhooks/src/eventProcessors/depositStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ export class DepositStatusProcessor implements IEventProcessor {
);
const webhookRequests =
await this.webhookRequests.findWebhookRequestsByFilter(filter);
const clientIds = webhookRequests.map((hook) => hook.clientId);
const uniqueClientIds = [
...new Set(webhookRequests.map((hook) => hook.clientId)),
];
const clients = await Promise.all(
clientIds.map((id) =>
uniqueClientIds.map((id) =>
this.webhookClientsRepository.getWebhookClientById(id),
),
);
Expand All @@ -68,24 +70,22 @@ export class DepositStatusProcessor implements IEventProcessor {
);

//TODO: unregister any hooks where event has reached terminal state
await Promise.all(
webhookRequests.map((hook) => {
const client = clientsMap[hook.clientId];
if (client) {
this.notify({
url: hook.url,
data: { ...event, webhookRequestId: hook.id },
apiKey: client.apiKey,
});
} else {
this.logger.error({
at: "DepositStatusProcessor::_write",
message: `Client not found for webhook request ${hook.id}`,
webhookRequest: hook,
});
}
}),
);
webhookRequests.forEach((hook) => {
const client = clientsMap[hook.clientId];
if (client) {
this.notify({
url: hook.url,
data: { ...event, webhookRequestId: hook.id },
apiKey: client.apiKey,
});
} else {
this.logger.error({
at: "DepositStatusProcessor::_write",
message: `Client not found for webhook request ${hook.id}`,
webhookRequest: hook,
});
}
});
}

write(e: unknown) {
Expand Down

0 comments on commit 5503792

Please sign in to comment.