Skip to content

Commit

Permalink
better req.query handling
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Nov 22, 2019
1 parent f04896a commit 8271f5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/fxa.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ const FXA = {
};
try {
log.info(`GETting ${fxaMetricsFlowUrl}, with options: ${JSON.stringify(fxaMetricsFlowOptions)}`);
const resp = await got(fxaMetricsFlowUrl, fxaMetricsFlowOptions);
const fxaResp = await got(fxaMetricsFlowUrl, fxaMetricsFlowOptions);
log.info("pinged FXA metrics flow.");
return resp;
return fxaResp;
} catch (e) {
log.error("sendMetricsFlowPing", {stack: e.stack});
return false;
}
},

Expand Down
6 changes: 3 additions & 3 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ async function recordVisitFromEmail (req, res, next) {
if (req.query.utm_medium && req.query.utm_medium !== "email") {
next();
}
if (!req.query.subscriber_id || !Number.isInteger(req.query.subscriber_id)) {
if (!req.query.subscriber_id || !Number.isInteger(Number(req.query.subscriber_id))) {
next();
}
const subscriber = await DB.getSubscriberById(req.query.subscriber_id);
if (!subscriber.fxa_uid) {
if (!subscriber.fxa_uid || subscriber.fxa_uid === "") {
next();
}
const fxaMetricsFlowPath = `metrics-flow?entrypoint=breach-alert-email&event_type=engage&uid=${subscriber.fxa_uid}&service=${AppConstants.OAUTH_CLIENT_ID}`;
await FXA.sendMetricsFlowPing(fxaMetricsFlowPath);
const fxaResult = await FXA.sendMetricsFlowPing(fxaMetricsFlowPath);
next();
}

Expand Down

0 comments on commit 8271f5b

Please sign in to comment.