Commit ad2d5e4d9294303e3a9695c47b895b7ec70b03be

Authored by Adhidarma Hadiwinoto
1 parent 5a60c2c73f
Exists in master

abaikan advice kadaluarsa

Showing 2 changed files with 13 additions and 5 deletions Side-by-side Diff

examples/kopnus/config.json
1 1 {
2 2 "auto_resend": {
3 3 "delay_ms": 60000,
4   - "max_retry": 1,
5   - "max_age_ms": 240000
  4 + "max_retry": 1
6 5 },
7 6 "sn_pattern": {
8 7 "pattern": "SN=(.*?)\\.",
9 8 "match_idx": 1
10   - }
  9 + },
  10 + "advice_max_age_ms": 240000,
  11 + "advice_is_topuprequest": true
11 12 }
... ... @@ -155,11 +155,18 @@ function _topUpInquiry(task) {
155 155 }
156 156  
157 157 function advice(task) {
158   - if (config && advice_is_not_allowed) {
  158 + if (config && config.advice_is_not_allowed) {
159 159 return;
160 160 }
161 161  
162   - if (config && advice_is_topuprequest) {
  162 + if (config && config.advice_max_age_ms) {
  163 + if (moment() - moment(task.created) > config.advice_max_age_ms) {
  164 + logger.verbose('Ignoring advice request because of expired task', {trx_id: task.trx_id, destination: task.destination, product: task.product, created: task.created, max_age: config.advice_max_age_ms});
  165 + return;
  166 + }
  167 + }
  168 +
  169 + if (config && config.advice_is_topuprequest) {
163 170 _topUpRequest(task, true);
164 171 }
165 172 else {