v1.18.0
This commit is contained in:
parent
6c34091634
commit
95379f731f
17 changed files with 187 additions and 99 deletions
|
@ -39,9 +39,11 @@ module.exports.countClick = (remoteIp, campaignCid, listCid, subscriptionCid, li
|
|||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
if(!data){
|
||||
|
||||
if (!data || data.campaign.trackingDisabled) {
|
||||
return callback(null, false);
|
||||
}
|
||||
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
@ -154,6 +156,10 @@ module.exports.countOpen = (remoteIp, campaignCid, listCid, subscriptionCid, cal
|
|||
return callback(err);
|
||||
}
|
||||
|
||||
if (!data || data.campaign.trackingDisabled) {
|
||||
return callback(null, false);
|
||||
}
|
||||
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
@ -260,6 +266,10 @@ module.exports.add = (url, campaignId, callback) => {
|
|||
};
|
||||
|
||||
module.exports.updateLinks = (campaign, list, subscription, serviceUrl, message, callback) => {
|
||||
if (campaign.trackingDisabled) {
|
||||
// tracking is disabled, do not modify the message
|
||||
return setImmediate(() => callback(null, message));
|
||||
}
|
||||
let re = /(<a[^>]* href\s*=[\s"']*)(http[^"'>\s]+)/gi;
|
||||
let urls = new Set();
|
||||
(message || '').replace(re, (match, prefix, url) => {
|
||||
|
@ -272,7 +282,7 @@ module.exports.updateLinks = (campaign, list, subscription, serviceUrl, message,
|
|||
// insert tracking image
|
||||
let inserted = false;
|
||||
let imgUrl = urllib.resolve(serviceUrl, util.format('/links/%s/%s/%s', campaign.cid, list.cid, encodeURIComponent(subscription.cid)));
|
||||
let img = '<img src="' + imgUrl + '" width="1" height="1" alt="Tracking Image">';
|
||||
let img = '<img src="' + imgUrl + '" width="1" height="1" alt="mt">';
|
||||
message = message.replace(/<\/body\b/i, match => {
|
||||
inserted = true;
|
||||
return img + match;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue