Skip to content
Snippets Groups Projects
Commit dc5fc42c authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Merge branch 'm_1083402_mailbridge_bouncelogging' into '2021.1.1'

[Projekt: xRM-Marketing][TicketNr.: 1083402][Bounces: Review und Einrichtung...

See merge request xrm/basic!1103
parents 6f35324c 8bf6a679
No related branches found
No related tags found
No related merge requests found
......@@ -35,18 +35,67 @@ IncomingEmailFilterProcessor.prototype.loadFilters = function ()
*/
IncomingEmailFilterProcessor.prototype.process = function (pEmail)
{
var mailLogId = this.checkBodyForMailLogId(pEmail);
var bouncedStatus = null;
this.emailFilters.forEach(function (emailFilter)
{
if (emailFilter.checkEmail(pEmail))
{
emailFilter.startWorkflow();
if(mailLogId)
{
var contactId = newSelect("CONTACT_ID")
.from("MAIL_LOG")
.where("MAIL_LOG.MAIL_LOGID", mailLogId)
.cell();
var recipientEmail = newSelect("RECIPIENT_EMAIL")
.from("MAIL_LOG")
.where("MAIL_LOG.MAIL_LOGID", mailLogId)
.cell();
emailFilter.startWorkflow(contactId,recipientEmail);
}
bouncedStatus = emailFilter.type;
}
});
if(bouncedStatus && mailLogId)
{
this.updateMailLog(bouncedStatus, mailLogId);
}
return bouncedStatus;
}
/*
*Checks the Email for a maillogid to document the possible bounce
*/
IncomingEmailFilterProcessor.prototype.checkBodyForMailLogId = function (pEmail)
{
var body = pEmail[mail.MAIL_TEXT];
var mailLogMatch = body.match(/log=([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/);
return mailLogMatch?mailLogMatch[1]:null;
}
/*
*Updates the matched maillog entry to document the bounce
**/
IncomingEmailFilterProcessor.prototype.updateMailLog = function (pBounceType, pMailLogId)
{
var recipientStatus;
switch(pBounceType)
{
case $KeywordRegistry.emailFilterType$bounceHard():
recipientStatus = $KeywordRegistry.bulkMailRecipientStatus$hardBounce();
break;
case $KeywordRegistry.emailFilterType$bounceSoft():
recipientStatus= $KeywordRegistry.bulkMailRecipientStatus$softBounce();
break;
}
newWhere("MAIL_LOG.MAIL_LOGID", pMailLogId).updateFields({"STATUS":recipientStatus});
}
IncomingEmailFilterProcessor.prototype.processError = function (pErrorMessage, pContactId, pEmailAddress)
{
var bouncedStatus = null;
......
......@@ -303,17 +303,17 @@ JditoFilter.prototype.checkRecord = function (pRow)
switch (pOperator)
{
case "CONTAINS":
return (new RegExp(pFilterValue, regexFlags)).test(pRowValue);
return (new RegExp(RegExpUtils.escapePatternStr(pFilterValue), regexFlags)).test(pRowValue);
case "CONTAINSNOT":
return !(new RegExp(pFilterValue, regexFlags)).test(pRowValue);
return !(new RegExp(RegExpUtils.escapePatternStr(pFilterValue), regexFlags)).test(pRowValue);
case "STARTSWITH":
return (new RegExp("^" + pFilterValue, regexFlags)).test(pRowValue);
return (new RegExp("^" + RegExpUtils.escapePatternStr(pFilterValue), regexFlags)).test(pRowValue);
case "ENDSWITH":
return (new RegExp(pFilterValue + "$", regexFlags)).test(pRowValue);
return (new RegExp(RegExpUtils.escapePatternStr(pFilterValue) + "$", regexFlags)).test(pRowValue);
case "EQUAL":
return (new RegExp("^" + pFilterValue + "$", regexFlags)).test(pRowValue);
return (new RegExp("^" + RegExpUtils.escapePatternStr(pFilterValue) + "$", regexFlags)).test(pRowValue);
case "NOT_EQUAL":
return !(new RegExp("^" + pFilterValue + "$", regexFlags)).test(pRowValue);
return !(new RegExp("^" + RegExpUtils.escapePatternStr(pFilterValue) + "$", regexFlags)).test(pRowValue);
case "LESS":
return pRowValue < pFilterValue;
case "LESS_OR_EQUAL":
......
......@@ -52,7 +52,7 @@ else
"MEDIUM": medium,
"STATUS": status,
"USER_NEW":"workflow",
"DATE_NEW":date
"DATE_NEW":currentDate
});
new SqlBuilder()
.tableName("COMMUNICATIONLEGALBASE")
......@@ -61,6 +61,6 @@ else
"COMMUNICATIONSETTINGS_ID": settingsId,
"VERSION": 1,
"USER_NEW":"workflow",
"DATE_NEW":date
"DATE_NEW":currentDate
});
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment