Skip to content

Commit 78b503d

Browse files
committed
fixes #10
1 parent 129a469 commit 78b503d

File tree

7 files changed

+17
-11
lines changed

7 files changed

+17
-11
lines changed

services/init-resource.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
lastSize: 0,
1010
lastHash: '',
1111
ctChecks: 0,
12-
whenLastCheck: moment.utc('0', 'x').format(),
12+
whenLastCheck: new Date(moment.utc('0', 'x').format()),
1313
ctUpdates: 0,
14-
whenLastUpdate: moment.utc('0', 'x').format()
14+
whenLastUpdate: new Date(moment.utc('0', 'x').format())
1515
};
1616

1717
return Object.assign({}, defaultResource, resource);

services/init-subscription.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
function initSubscription(subscriptions, notifyProcedure, apiurl, protocol) {
88
const defaultSubscription = {
99
ctUpdates: 0,
10-
whenLastUpdate: moment.utc('0', 'x').format(),
10+
whenLastUpdate: new Date(moment.utc('0', 'x').format()),
1111
ctErrors: 0,
1212
ctConsecutiveErrors: 0,
13-
whenLastError: moment.utc('0', 'x').format(),
14-
whenExpires: moment().utc().add(config.ctSecsResourceExpire, 'seconds').format(),
13+
whenLastError: new Date(moment.utc('0', 'x').format()),
14+
whenExpires: new Date(moment().utc().add(config.ctSecsResourceExpire, 'seconds').format()),
1515
url: apiurl,
1616
notifyProcedure,
1717
protocol

services/notify-one-challenge.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"use strict";
33

44
const config = require('../config'),
5+
ErrorResponse = require('./error-response'),
56
notifyOne = require('./notify-one'),
67
getRandomPassword = require('./get-random-password'),
78
querystring = require('querystring'),
@@ -14,13 +15,16 @@
1415
'challenge': challenge
1516
}),
1617
res = await request({
18+
method: 'GET',
19+
followRedirect: true,
20+
maxRedirects: 3,
1721
uri: testUrl,
1822
timeout: config.requestTimeout,
1923
resolveWithFullResponse: true
2024
});
2125

2226
if (res.statusCode < 200 || res.statusCode > 299 || res.body !== challenge) {
23-
throw new Error('Notification Failed');
27+
throw new ErrorResponse('Notification Failed');
2428
}
2529
}
2630

services/notify-one.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
async function notifyOneRest(apiurl, resourceUrl) {
1010
const res = await request({
1111
method: 'POST',
12+
followRedirect: true,
13+
maxRedirects: 3,
1214
uri: apiurl,
1315
timeout: config.requestTimeout,
1416
form: {

services/notify-subscribers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
subscription.ctUpdates += 1;
4444
subscription.ctConsecutiveErrors = 0;
45-
subscription.whenLastUpdate = moment().utc().format();
45+
subscription.whenLastUpdate = new Date(moment().utc().format());
4646

4747
await logEvent(
4848
'Notify',
@@ -54,7 +54,7 @@
5454

5555
subscription.ctErrors += 1;
5656
subscription.ctConsecutiveErrors += 1;
57-
subscription.whenLastError = moment().utc().format();
57+
subscription.whenLastError = new Date(moment().utc().format());
5858

5959
await logEvent(
6060
'NotifyFailed',

services/ping.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
}
4545

4646
resource.ctChecks += 1;
47-
resource.whenLastCheck = moment().utc().format();
47+
resource.whenLastCheck = new Date(moment().utc().format());
4848

4949
if (res.statusCode < 200 || res.statusCode > 299) {
5050
throw new ErrorResponse(sprintf(appMessage.error.ping.readResource, resourceUrl));
@@ -93,7 +93,7 @@
9393
async function notifySubscribersIfDirty(resource, resourceUrl) {
9494
if (resource.flDirty) {
9595
resource.ctUpdates += 1;
96-
resource.whenLastUpdate = moment().utc().format();
96+
resource.whenLastUpdate = new Date(moment().utc().format());
9797
return await notifySubscribers(resourceUrl);
9898
}
9999
}

services/please-notify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
subscriptions.pleaseNotify[index].ctUpdates += 1;
7575
subscriptions.pleaseNotify[index].ctConsecutiveErrors = 0;
76-
subscriptions.pleaseNotify[index].whenLastUpdate = moment().utc().format();
76+
subscriptions.pleaseNotify[index].whenLastUpdate = new Date(moment().utc().format());
7777
subscriptions.pleaseNotify[index].whenExpires = moment().utc().add(config.ctSecsResourceExpire, 'seconds').format();
7878

7979
await upsertSubscriptions(subscriptions);

0 commit comments

Comments
 (0)