Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/core-webhooks/__tests__/listener.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const mockEventDispatcher = {
dispatch: jest.fn(),
};

const webhooksConfiguration = {
getRequired: jest.fn().mockReturnValue(2000),
};

let spyOnPost: jest.SpyInstance;

const expectFinishedEventData = () => {
Expand Down Expand Up @@ -54,6 +58,7 @@ beforeEach(() => {
sandbox.app.bind<Database>(Identifiers.Database).to(Database).inSingletonScope();

sandbox.app.bind(Container.Identifiers.LogService).toConstantValue(logger);
sandbox.app.bind(Container.Identifiers.PluginConfiguration).toConstantValue(webhooksConfiguration);

database = sandbox.app.get<Database>(Identifiers.Database);
database.boot();
Expand Down
15 changes: 12 additions & 3 deletions packages/core-webhooks/src/listener.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Container, Contracts, Utils } from "@arkecosystem/core-kernel";
import { Container, Contracts, Providers, Utils } from "@arkecosystem/core-kernel";
import { performance } from "perf_hooks";

import * as conditions from "./conditions";
Expand Down Expand Up @@ -37,6 +37,15 @@ export class Listener {
@Container.inject(Container.Identifiers.LogService)
private readonly logger!: Contracts.Kernel.Logger;

/**
* @private
* @type {Providers.PluginConfiguration}
* @memberof Listener
*/
@Container.inject(Container.Identifiers.PluginConfiguration)
@Container.tagged("plugin", "@arkecosystem/core-webhooks")
private readonly webhooksConfiguration!: Providers.PluginConfiguration;

/**
* @param {string} event
* @memberof Listener
Expand Down Expand Up @@ -64,7 +73,7 @@ export class Listener {
* @returns {Promise<void>}
* @memberof Broadcaster
*/
public async broadcast(webhook: Webhook, payload: object, timeout: number = 1500): Promise<void> {
public async broadcast(webhook: Webhook, payload: object): Promise<void> {
const start = performance.now();

try {
Expand All @@ -77,7 +86,7 @@ export class Listener {
headers: {
Authorization: webhook.token,
},
timeout,
timeout: this.webhooksConfiguration.getRequired("timeout"),
});

this.logger.debug(
Expand Down