Skip to content

Commit ea73d10

Browse files
committed
FEATURE: add support of endDates for subscribers
1 parent 686529e commit ea73d10

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ const openRoutes = {
139139
const query = url.parse(req.url, true).query;
140140
if (query.referer ? payment.referer === query.referer : true) {
141141
const email = payment.email;
142-
const isFresh = query.startDate ? (Date.parse(payment.date) - Date.parse(query.startDate) > 0) : true;
143-
if (isFresh && email) {
142+
const isFreshStart = query.startDate ? (Date.parse(payment.date) - Date.parse(query.startDate) > 0) : true;
143+
const isFreshEnd = query.endDate ? (Date.parse(query.endDate) - Date.parse(payment.date) > 0) : true;
144+
if (isFreshStart && isFreshEnd && email) {
144145
const currentAmount = (subscribers[email] && subscribers[email].amount) || 0;
145146
payment.amount += currentAmount;
146147
subscribers[email] = payment;

0 commit comments

Comments
 (0)