diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js index da334e18d5289ef99c6574daef1006cf9ed8b858..5308da47b3c321a392a0c73509b84648ef9f04a0 100644 --- a/process/Bulkmail_lib/process.js +++ b/process/Bulkmail_lib/process.js @@ -156,10 +156,18 @@ BulkMailUtils.sendBulkMail = function (pBulkMailId, pIsTestRun) return new Placeholder(placeholder, Placeholder.types.FIXEDVALUE, url); }); + var webviewFn = function(pContactId) + { + return vars.get("$sys.origin")+"/services/rest/webview_rest?" + "log=" + mailLogIds.get(pContactId); + } + var webviewPlaceholder = new Placeholder("webview", Placeholder.types.CALLBACKFUNCTION, webviewFn); + + var additionalPlaceholders = [webviewPlaceholder].concat(linkPlaceholders); + var successIds = []; var failedIds = []; var sentDate = vars.get("$sys.date"); - var mails = template.getReplacedEmailsByContactIds(contactIds, linkPlaceholders); + var mails = template.getReplacedEmailsByContactIds(contactIds, additionalPlaceholders); var subjectTemplate = new DocumentTemplate(subject, DocumentTemplate.types.PLAIN); var subjects = subjectTemplate.getReplacedContentByContactIds(contactIds); diff --git a/process/webview_rest/process.js b/process/webview_rest/process.js new file mode 100644 index 0000000000000000000000000000000000000000..ec9191374d7ca7dccb117faa3c98a3a5784df4a8 --- /dev/null +++ b/process/webview_rest/process.js @@ -0,0 +1,44 @@ +import("Email_lib"); +import("Sql_lib"); +import("Workflow_lib"); +import("Util_lib"); +import("system.util"); +import("Bulkmail_lib"); + +function restget (pRequest) +{ + var request = JSON.parse(pRequest); + var mailLogId = request.query.log; + + + + if (mailLogId) + { + try + { + var BulkMailId,MailRunId; + [BulkMailId,MailRunId] = newSelect(["MAIL_RUN.OBJECT_ROWID","MAIL_RUN.MAIL_RUNID"]) + .from("MAIL_LOG") + .join("MAIL_RUN","MAIL_RUN.MAIL_RUNID = MAIL_LOG.MAIL_RUN_ID") + .where("MAIL_LOG.MAIL_LOGID",mailLogId) + .arrayRow(); + var eml = BulkMailUtils.getEmlFile(BulkMailId, MailRunId, mailLogId); + var email = Email.fromRFC(eml); + + request.response.httpStatusCode = 200; //Ok + request.response.header["Content-Type"] = "text/html"; + request.response.body = email.body; + + } + catch (ex) + { + request.response.httpStatusCode = 404; //not found + } + } + else + { + request.response.httpStatusCode = 400; //bad request + } + + return JSON.stringify(request); +} diff --git a/process/webview_rest/webview_rest.aod b/process/webview_rest/webview_rest.aod new file mode 100644 index 0000000000000000000000000000000000000000..75dd99189132ec8688d146be1f7d80eda100ebfe --- /dev/null +++ b/process/webview_rest/webview_rest.aod @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.2"> + <name>webview_rest</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/webview_rest/process.js</process> + <publishAsWebservice v="true" /> + <style>REST</style> + <loginTypeId> + <element>internal.none</element> + </loginTypeId> + <alias>Data_alias</alias> + <variants> + <element>EXECUTABLE</element> + </variants> +</process>