From ff2b3b4e10d8b2d659a4a969d1a72c88e9b9bbb4 Mon Sep 17 00:00:00 2001 From: Skorpios Date: Sun, 16 Feb 2025 20:28:34 -0800 Subject: [PATCH] Removed timing request for the webhook. --- Server/service/networkService.js | 64 +++++++++++++++----------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/Server/service/networkService.js b/Server/service/networkService.js index 9d0342d27..7b49184b6 100644 --- a/Server/service/networkService.js +++ b/Server/service/networkService.js @@ -437,46 +437,40 @@ class NetworkService { async requestWebhook(platform, url, message) { try { - const { response, responseTime, error } = await this.timeRequest(() => - this.axios.post(url, message, { - headers: { - 'Content-Type': 'application/json' - } - }) - ); + const response = await this.axios.post(url, message, { + headers: { + 'Content-Type': 'application/json' + } + }); - const webhookResponse = { + return { type: 'webhook', - responseTime, - payload: response?.data + status: true, + code: response.status, + message: `Successfully sent ${platform} notification`, + payload: response.data }; - if (error) { - webhookResponse.status = false; - webhookResponse.code = error.response?.status || this.NETWORK_ERROR; - webhookResponse.message = `Failed to send ${platform} notification`; - this.logger.warn({ - message: error.message, - service: this.SERVICE_NAME, - method: 'requestWebhook', - url, - platform, - error: error.message, - statusCode: error.response?.status, - responseData: error.response?.data, - requestPayload: message - }); - return webhookResponse; - } - - webhookResponse.status = true; - webhookResponse.code = response.status; - webhookResponse.message = `Successfully sent ${platform} notification`; - return webhookResponse; } catch (error) { - error.service = this.SERVICE_NAME; - error.method = 'requestWebhook'; - throw error; + this.logger.warn({ + message: error.message, + service: this.SERVICE_NAME, + method: 'requestWebhook', + url, + platform, + error: error.message, + statusCode: error.response?.status, + responseData: error.response?.data, + requestPayload: message + }); + + return { + type: 'webhook', + status: false, + code: error.response?.status || this.NETWORK_ERROR, + message: `Failed to send ${platform} notification`, + payload: error.response?.data + }; } }