Skip to content
This repository was archived by the owner on Dec 28, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ app.get('/unsubscribe/:email', function (req, res) {
if (req.params.email) {
const email = validator.parseOneAddress(req.params.email)
if (email === null) {
logger.warning(`Got invalid email address : ${req.params.email}`)
logger.info(`Got invalid email address : ${req.params.email}`)
}
else {
subscription.unsubscribe(email.address)
}
}
else {
logger.warning('got no email address - ignoring request')
logger.info('got no email address - ignoring request')
}
res.redirect('/unsubscribed')
})
app.get('/subscribe/:email', function (req, res) {
if (req.params.email) {
const email = validator.parseOneAddress(req.params.email)
if (email === null) {
logger.warning(`Got invalid email address : ${req.params.email}`)
logger.info(`Got invalid email address : ${req.params.email}`)
res.status(400).send('invalid email')
}
else {
Expand Down
4 changes: 2 additions & 2 deletions subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ module.exports = function (mailgun) {
},
function (err, body) {
if (err) {
logger.error(`could not ${sub ? '' : 'un'}subscribe : ${email} : ${err} : ${body}`)
logger.error(`could not ${sub ? '' : 'un'}subscribe : ${email} : ${err}`)
}
else {
logger.debug(`${sub ? '' : 'un'}subscribed : ${email} : ${body}`)
logger.debug(`${sub ? '' : 'un'}subscribed : ${email}`)
}
})
}
Expand Down