v1.8.1
This commit is contained in:
parent
01fe8d0dbc
commit
d933f07eac
4 changed files with 28 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
## 1.8.1 2016-05-13
|
||||
|
||||
* Fixed an issue in API
|
||||
|
||||
## 1.8.0 2016-05-13
|
||||
|
||||
* Show details about subscribers who clicked on a specific link
|
||||
|
|
|
@ -345,6 +345,24 @@ module.exports.insert = (listId, meta, subscription, callback) => {
|
|||
statusDirection = !existing ? (meta.status === 1 ? '+' : '-') : (existing.status === 1 ? '-' : '+');
|
||||
}
|
||||
|
||||
if (!keys.length) {
|
||||
// nothing to update
|
||||
return connection.commit(err => {
|
||||
if (err) {
|
||||
return connection.rollback(() => {
|
||||
connection.release();
|
||||
return callback(err);
|
||||
});
|
||||
}
|
||||
connection.release();
|
||||
return callback(null, {
|
||||
entryId,
|
||||
cid: meta.cid,
|
||||
inserted: !existing
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (!existing) {
|
||||
// insert as new
|
||||
keys = insertKeys.concat(keys);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "mailtrain",
|
||||
"private": true,
|
||||
"version": "1.8.0",
|
||||
"version": "1.8.1",
|
||||
"description": "Self hosted email newsletter app",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -6,6 +6,7 @@ let fields = require('../lib/models/fields');
|
|||
let subscriptions = require('../lib/models/subscriptions');
|
||||
let tools = require('../lib/tools');
|
||||
let express = require('express');
|
||||
let log = require('npmlog');
|
||||
let router = new express.Router();
|
||||
|
||||
router.all('/*', (req, res, next) => {
|
||||
|
@ -44,6 +45,7 @@ router.post('/subscribe/:listId', (req, res) => {
|
|||
});
|
||||
lists.getByCid(req.params.listId, (err, list) => {
|
||||
if (err) {
|
||||
log.error('API', err);
|
||||
res.status(500);
|
||||
return res.json({
|
||||
error: err.message || err,
|
||||
|
@ -66,6 +68,7 @@ router.post('/subscribe/:listId', (req, res) => {
|
|||
}
|
||||
tools.validateEmail(input.EMAIL, false, err => {
|
||||
if (err) {
|
||||
log.error('API', err);
|
||||
res.status(400);
|
||||
return res.json({
|
||||
error: err.message || err,
|
||||
|
@ -121,6 +124,7 @@ router.post('/subscribe/:listId', (req, res) => {
|
|||
if (/^(yes|true|1)$/i.test(input.REQUIRE_CONFIRMATION)) {
|
||||
subscriptions.addConfirmation(list, input.EMAIL, subscription, (err, cid) => {
|
||||
if (err) {
|
||||
log.error('API', err);
|
||||
res.status(500);
|
||||
return res.json({
|
||||
error: err.message || err,
|
||||
|
@ -137,6 +141,7 @@ router.post('/subscribe/:listId', (req, res) => {
|
|||
} else {
|
||||
subscriptions.insert(list.id, meta, subscription, (err, response) => {
|
||||
if (err) {
|
||||
log.error('API', err);
|
||||
res.status(500);
|
||||
return res.json({
|
||||
error: err.message || err,
|
||||
|
|
Loading…
Reference in a new issue