Skip to content

Commit

Permalink
Merge pull request #4774 from Countly/SER-1026-message-timeout-parameter
Browse files Browse the repository at this point in the history
[SER-1026] [push] Timeout parameter for push
  • Loading branch information
coskunaydinoglu authored Dec 14, 2023
2 parents 90de16e + 4642374 commit 67c8e14
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion plugins/push/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion plugins/push/api/jobs/util/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions plugins/push/api/send/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions plugins/push/frontend/public/localization/push.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 67c8e14

Please sign in to comment.