From 4642374b8f323f614e1287fa177df51752a95414 Mon Sep 17 00:00:00 2001 From: Cihad Tekin Date: Tue, 12 Dec 2023 16:06:25 +0300 Subject: [PATCH] [SER-1026] Updated push settings to be able to parameterize message timeout --- plugins/push/api/api.js | 3 ++- plugins/push/api/jobs/util/connector.js | 2 +- plugins/push/api/send/sender.js | 8 ++++++++ plugins/push/frontend/public/localization/push.properties | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/push/api/api.js b/plugins/push/api/api.js index bee4cfd690a..15d4f1be6f3 100644 --- a/plugins/push/api/api.js +++ b/plugins/push/api/api.js @@ -65,7 +65,8 @@ plugins.setConfigs(FEATURE_NAME, { pool_pushes: 400, // object mode streams high water mark pool_bytes: 10000, // bytes mode streams high water mark pool_concurrency: 5, // max number of same type connections - pool_pools: 10 // max number of connections in total + pool_pools: 10, // max number of connections in total + message_timeout: 3600000, // timeout for a message not sent yet (for TooLateToSend error) }); plugins.internalEvents.push('[CLY]_push_sent'); diff --git a/plugins/push/api/jobs/util/connector.js b/plugins/push/api/jobs/util/connector.js index ec9d87533a1..ca81f15a62a 100644 --- a/plugins/push/api/jobs/util/connector.js +++ b/plugins/push/api/jobs/util/connector.js @@ -169,7 +169,7 @@ class Connector extends DoFinish { } }, callback); } - else if (push._id.getTimestamp().getTime() < Date.now() - 3600000) { + else if (push._id.getTimestamp().getTime() < Date.now() - this.state.cfg.message_timeout) { this.tooLateToSend.addAffected(push._id, 1); this.do_flush(callback, true); return; diff --git a/plugins/push/api/send/sender.js b/plugins/push/api/send/sender.js index b046a7f9876..76b84204253 100644 --- a/plugins/push/api/send/sender.js +++ b/plugins/push/api/send/sender.js @@ -120,6 +120,14 @@ class Sender { auth: !(plugins.push.proxyunauthorized || false), }; } + if (plugins.push.message_timeout) { + if (typeof plugins.push.message_timeout === "number") { + cfg.message_timeout = plugins.push.message_timeout; + } + else { + common.log(`push:send`).w('Invalid message timeout configuration: %j', plugins.push.message_timeout); + } + } } return cfg; diff --git a/plugins/push/frontend/public/localization/push.properties b/plugins/push/frontend/public/localization/push.properties index 8fbd3b8ba52..d8c3b41d6c9 100755 --- a/plugins/push/frontend/public/localization/push.properties +++ b/plugins/push/frontend/public/localization/push.properties @@ -419,6 +419,7 @@ push.pool_pushes = Number of notifications in stream batches push.pool_bytes = Bytes in binary stream batches push.pool_concurrency = Maximum number of same type connections push.pool_pools = Maximum number of connections in total +push.message_timeout = Timeout of a message to be send #Drawer from other views push-notification.send-message-to-users = Send message to users