diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js index 0a4abe43994a04bfa2febe4d21de4e20fa6c8c5c..0b25ca2095455a647655fd9e105b0ecc7ee90465 100644 --- a/process/Bulkmail_lib/process.js +++ b/process/Bulkmail_lib/process.js @@ -29,6 +29,7 @@ import("system.db"); import("system.workflow"); import("system.tools"); import("FileUtil_lib"); +import("system.text"); /** * Functions for bulk mails. @@ -181,15 +182,23 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pIsTestRun, pUser, pAddition .table() .map(function ([placeholder, weblinkId, url, isRedirect]) { + var linkFn if (Utils.toBoolean(isRedirect)) { - var linkFn = function (pContactId) + linkFn = function (pContactId) { return baseUrl + "link=" + weblinkId + "&log=" + mailLogIds.get(pContactId) + additionalParameterString; } return new Placeholder(placeholder, Placeholder.types.CALLBACKFUNCTION, linkFn); } - return new Placeholder(placeholder, Placeholder.types.FIXEDVALUE, url); + else + { + linkFn = function (pContactId) + { + return StringUtils.replaceAll(url, "{@contactid@}", pContactId); + } + return new Placeholder(placeholder, Placeholder.types.CALLBACKFUNCTION, linkFn); + } }); var webviewFn = function(pContactId) @@ -1012,15 +1021,22 @@ BulkMailUtils.getEmlFile = function(pBulkMailId,pMailRunId, pMailLogId) * The id of the link.<br> * @param {String} pBaseUrl <p> * The base url for relative links<br> - * + * @param {String} pMailLogId <p> + * The mail log id for contact id replacement<br> * @return {String} <p> * The url<br> **/ -BulkMailUtils.getRedirectLink = function(pLinkId, pBaseUrl) +BulkMailUtils.getRedirectLink = function(pLinkId, pBaseUrl, pMailLogId) { - if (pLinkId) + if (pLinkId && pMailLogId) { + var contactId = newSelect("CONTACT_ID") + .from("MAIL_LOG") + .where("MAIL_LOG.MAIL_LOGID", pMailLogId) + .cell(); var link = newSelect("WEBLINK.URL").from("WEBLINK").where("WEBLINK.WEBLINKID", pLinkId).cell(); + + link = StringUtils.replaceAll(link, "{@contactid@}", contactId); if(link[0] == "/") { link = pBaseUrl + link; diff --git a/process/redirect_rest/process.js b/process/redirect_rest/process.js index eb1da60e6fc71fb4c8eca92f8bf88c0a795b13c5..026a60e324caa25c0bd1cd15364a375b075e3ed0 100644 --- a/process/redirect_rest/process.js +++ b/process/redirect_rest/process.js @@ -16,7 +16,7 @@ function restget (pRequest) var workflowKey = request.query.workflowkey var ipAddress = BulkMailUtils.getIpAddressFromHeader(request.header); var origin =request.header["X-forwarded-proto"]+"://"+request.header["X-forwarded-host"] - var redirectLink = BulkMailUtils.getRedirectLink(linkId, origin); + var redirectLink = BulkMailUtils.getRedirectLink(linkId, origin, mailLogId); var UserAgentObject = new UAParser(request.header["User-agent"]).getResult(); BulkMailUtils.insertClick(mailLogId, ipAddress, linkId, UserAgentObject.browser.name, UserAgentObject.os.name, UserAgentObject.device.type);