Improved App.Utils.signatureIdentify(), if an agent message is checked, just different detection priority.
This commit is contained in:
parent
af746d8f21
commit
0201d44c69
3 changed files with 39 additions and 24 deletions
|
@ -118,8 +118,10 @@ class ArticleViewItem extends App.Controller
|
||||||
|
|
||||||
# prepare html body
|
# prepare html body
|
||||||
if @article.content_type is 'text/html'
|
if @article.content_type is 'text/html'
|
||||||
@article['html'] = @article.body
|
if @article.sender.type is 'Agent'
|
||||||
@article['html'] = App.Utils.signatureIdentify( @article['html'] )
|
@article['html'] = App.Utils.signatureIdentify(@article.body, false, true)
|
||||||
|
else
|
||||||
|
@article['html'] = App.Utils.signatureIdentify(@article.body)
|
||||||
else
|
else
|
||||||
|
|
||||||
# client signature detection
|
# client signature detection
|
||||||
|
|
|
@ -247,13 +247,12 @@ class App.Utils
|
||||||
true
|
true
|
||||||
|
|
||||||
# messageWithMarker = App.Utils.signatureIdentify(message, false)
|
# messageWithMarker = App.Utils.signatureIdentify(message, false)
|
||||||
@signatureIdentify: (message, test = false) ->
|
@signatureIdentify: (message, test = false, internal = false) ->
|
||||||
textToSearch = @html2text(message)
|
textToSearch = @html2text(message)
|
||||||
|
|
||||||
# if we do have less then 8 lines and less then 300 chars ignore this
|
# if we do have less then 8 lines and less then 300 chars ignore this
|
||||||
textToSearchInLines = textToSearch.split("\n")
|
textToSearchInLines = textToSearch.split("\n")
|
||||||
if !test
|
return message if !test && (textToSearchInLines.length < 8 && textToSearch.length < 300)
|
||||||
return message if textToSearchInLines.length < 8 && textToSearch.length < 300
|
|
||||||
|
|
||||||
quote = (str) ->
|
quote = (str) ->
|
||||||
(str + '').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&")
|
(str + '').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&")
|
||||||
|
@ -417,8 +416,8 @@ class App.Utils
|
||||||
markerTemplate = '<span class="js-signatureMarker"></span>'
|
markerTemplate = '<span class="js-signatureMarker"></span>'
|
||||||
|
|
||||||
# search for zammad
|
# search for zammad
|
||||||
# <div data-signature="true" data-signature-id=".{1,3}">
|
# <div data-signature="true" data-signature-id=".{1,5}">
|
||||||
if !markers || !markers[0]
|
if !markers || !markers[0] || internal
|
||||||
regex = new RegExp("(<div data-signature=\"true\" data-signature-id=\".{1,5}\">)")
|
regex = new RegExp("(<div data-signature=\"true\" data-signature-id=\".{1,5}\">)")
|
||||||
if message.match(regex)
|
if message.match(regex)
|
||||||
return message.replace(regex, "#{markerTemplate}\$1")
|
return message.replace(regex, "#{markerTemplate}\$1")
|
||||||
|
|
|
@ -726,13 +726,27 @@ test("identify signature", function() {
|
||||||
result = App.Utils.signatureIdentify(message, true)
|
result = App.Utils.signatureIdentify(message, true)
|
||||||
equal(result, should)
|
equal(result, should)
|
||||||
|
|
||||||
|
message = "Dear Mr. Smith,<div><br></div><div>it seems to be, dass Sie den AutoIncrement Nummerngenerator für Ihre ITSMChangeManagement Installation verwenden. Seit ABC 3.2 wird führend vor der sich in der Datei <span style=\"line-height: 1.45; background-color: initial;\"><ABC_CONFIG_Home>/war/log/ITSMChangeCounter.log befindenden Zahl die SystemID (SysConfig) geschrieben. Dies ist ein Standardverhalten, dass auch bei der Ticketnummer verwendet wird.<br><br>Please ask me if you have questions.</span></div><div><span style=\"line-height: 1.45; background-color: initial;\"><br></span></div><div><span style=\"line-height: 1.45; background-color: initial;\">Viele Grüße,</span></div><div><div data-signature=\"true\" data-signature-id=\"1\"> Thorsten Smith\n<br>\n<br>--\n<br>Enterprise Services for ABC\n<br>\n<br>Znuny GmbH // Marienstraße 11 // 10117 Berlin // Germany\n<br>\n<br>P: +49 (0) 30 111 111 111-0\n<br>F: +49 (0) 30 111 111 111-8\n<br>W: http://znuny.com \n<br>\n<br>Location: Berlin - HRB 12345678 B Amtsgericht Berlin-Charlottenburg\n<br>Managing Director: Martin Edenhofer\n<br></div></div>"
|
||||||
|
should = "Dear Mr. Smith,<div><br></div><div>it seems to be, dass Sie den AutoIncrement Nummerngenerator für Ihre ITSMChangeManagement Installation verwenden. Seit ABC 3.2 wird führend vor der sich in der Datei <span style=\"line-height: 1.45; background-color: initial;\"><ABC_CONFIG_Home>/war/log/ITSMChangeCounter.log befindenden Zahl die SystemID (SysConfig) geschrieben. Dies ist ein Standardverhalten, dass auch bei der Ticketnummer verwendet wird.<br><br>Please ask me if you have questions.</span></div><div><span style=\"line-height: 1.45; background-color: initial;\"><br></span></div><div><span style=\"line-height: 1.45; background-color: initial;\">Viele Grüße,</span></div><div><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"1\"> Thorsten Smith\n<br>\n<br>--\n<br>Enterprise Services for ABC\n<br>\n<br>Znuny GmbH // Marienstraße 11 // 10117 Berlin // Germany\n<br>\n<br>P: +49 (0) 30 111 111 111-0\n<br>F: +49 (0) 30 111 111 111-8\n<br>W: http://znuny.com \n<br>\n<br>Location: Berlin - HRB 12345678 B Amtsgericht Berlin-Charlottenburg\n<br>Managing Director: Martin Edenhofer\n<br></div></div>"
|
||||||
|
result = App.Utils.signatureIdentify(message, true, true)
|
||||||
|
equal(result, should)
|
||||||
|
|
||||||
|
message = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"1\"> Thorsten Smith\n<br>\n<br>--\n</div></div>"
|
||||||
|
should = "Dear Mr. Smith, nice to read you,<div><span class=\"js-signatureMarker\"></span><div data-signature=\"true\" data-signature-id=\"1\"> Thorsten Smith\n<br>\n<br>--\n</div></div>"
|
||||||
|
result = App.Utils.signatureIdentify(message, true, true)
|
||||||
|
equal(result, should)
|
||||||
|
|
||||||
|
message = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"9999\"> Thorsten Smith\n<br>\n<br>--\n</div></div>"
|
||||||
|
should = "Dear Mr. Smith, nice to read you,<div><div data-signature=\"true\" data-signature-id=\"9999\"> Thorsten Smith\n<br>\n<br>--\n</div></div>"
|
||||||
|
result = App.Utils.signatureIdentify(message, false, true)
|
||||||
|
equal(result, should)
|
||||||
|
|
||||||
// fr
|
// fr
|
||||||
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>"
|
message = "<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>"
|
||||||
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>'
|
should = '<div>test 123 <br/><br/>--no not match--<br/><br/>Bob Smith<br/><span class="js-signatureMarker"></span>De : Martin Edenhofer via Znuny Support [mailto:support@znuny.inc]<br/>Envoyé : mercredi 29 avril 2015 17:31<br/>Objet : lalala</div>'
|
||||||
result = App.Utils.signatureIdentify(message, true)
|
result = App.Utils.signatureIdentify(message, true)
|
||||||
equal(result, should)
|
equal(result, should)
|
||||||
|
|
||||||
|
|
||||||
// thunderbird
|
// thunderbird
|
||||||
// de
|
// de
|
||||||
message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:</div><div>> Hallo Christian,</div>"
|
message = "<div><br></div><div>Viele Grüße,</div><div>Christian</div><div><br></div><div>Am 04.03.2015 um 12:47 schrieb Martin Edenhofer via Znuny Sales:</div><div>> Hallo Christian,</div>"
|
||||||
|
|
Loading…
Reference in a new issue