Skip to content

Commit

Permalink
return from middleware early
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Nov 22, 2019
1 parent 8271f5b commit fcb9ba5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,24 @@ function pickLanguage (req, res, next) {
async function recordVisitFromEmail (req, res, next) {
if (req.query.utm_source && req.query.utm_source !== "fx-monitor") {
next();
return;
}
if (req.query.utm_medium && req.query.utm_medium !== "email") {
next();
return;
}
if (!req.query.subscriber_id || !Number.isInteger(Number(req.query.subscriber_id))) {
next();
return;
}
const subscriber = await DB.getSubscriberById(req.query.subscriber_id);
if (!subscriber.fxa_uid || subscriber.fxa_uid === "") {
next();
return;
}
const fxaMetricsFlowPath = `metrics-flow?entrypoint=breach-alert-email&event_type=engage&uid=${subscriber.fxa_uid}&service=${AppConstants.OAUTH_CLIENT_ID}`;
const fxaResult = await FXA.sendMetricsFlowPing(fxaMetricsFlowPath);
log.info(`fxaResult: ${fxaResult}`);
next();
}

Expand Down

0 comments on commit fcb9ba5

Please sign in to comment.