Follow up: Issue #582 - long content type shows warning and gets cut.

This commit is contained in:
Thorsten Eckel 2017-01-16 10:01:20 +01:00
parent 9cb57cdbe6
commit 2c3ffbc897
3 changed files with 146 additions and 1 deletions

View file

@ -87,7 +87,7 @@ module Import
# so Zammad can set the default content type
mapped.delete(:content_type) if mapped[:content_type].blank?
return mapped if !mapped[:content_type]
mapped[:content_type].sub!(/;\s?.+?$/, '')
mapped[:content_type].sub!(/[;,]\s?.+?$/, '')
mapped
end

View file

@ -0,0 +1,108 @@
{
"Age": 63188310,
"PriorityID": "3",
"ContentType": "text/plain, charset=utf-8",
"AttachmentIDOfHTMLBody": "1",
"DynamicField_SugarCRMCompanySelection": null,
"ServiceID": null,
"TicketFreeText11": null,
"DynamicField_ITSMDueDate": "2014-11-24 00:15:00",
"DynamicField_Topic": null,
"StateID": "2",
"DynamicField_Hostname": null,
"Body": "test #3",
"DynamicField_ZammadMigratorChanged": null,
"EscalationTime": "0",
"Changed": "2014-11-21 00:21:08",
"OwnerID": "3",
"DynamicField_ZarafaTN": null,
"DynamicField_ProcessManagementActivityID": null,
"DynamicField_TopicID": null,
"DynamicField_ScomHostname": null,
"Owner": "agent-2",
"AgeTimeUnix": 63188309,
"TicketFreeKey11": null,
"ArticleID": "3970",
"Created": "2014-11-21 00:17:41",
"DynamicField_ScomUUID": null,
"DynamicField_TicketFreeText11": null,
"DynamicField_TicketFreeKey11": null,
"DynamicField_ITSMReviewRequired": "No",
"DynamicField_OpenExchangeTicketNumber": null,
"DynamicField_ITSMDecisionDate": null,
"ArticleTypeID": "5",
"QueueID": "1",
"ReplyTo": "",
"DynamicField_ITSMImpact": null,
"TicketID": "730",
"DynamicField_ITSMRecoveryStartTime": null,
"Cc": "",
"EscalationResponseTime": "0",
"DynamicField_ProcessManagementProcessID": null,
"IncomingTime": "1416525461",
"Charset": "utf-8",
"DynamicField_CheckboxExample": null,
"DynamicField_Location": null,
"CustomerUserID": "BetreuterKunde2",
"DynamicField_Vertriebsweg": null,
"Attachments": [
{
"ContentAlternative": "",
"ContentID": "",
"Disposition": "inline",
"Filesize": "201 Bytes",
"ContentType": "text/html; charset=\"utf-8\"",
"Filename": "ZmlsZS0y\n",
"FilesizeRaw": "201",
"Content": "PCFET0NUWVBFIGh0bWw+PGh0bWw+PGhlYWQ+PG1ldGEgaHR0cC1lcXVpdj0iQ29udGVudC1UeXBl\nIiBjb250ZW50PSJ0ZXh0L2h0bWw7IGNoYXJzZXQ9dXRmLTgiLz48L2hlYWQ+PGJvZHkgc3R5bGU9\nImZvbnQtZmFtaWx5OkdlbmV2YSxIZWx2ZXRpY2EsQXJpYWwsc2Fucy1zZXJpZjsgZm9udC1zaXpl\nOiAxMnB4OyI+dGVzdCAjMzwvYm9keT48L2h0bWw+\n"
}
],
"DynamicField_CustomerLocation": null,
"DynamicField_SugarCRMRemoteID": null,
"DynamicField_OpenExchangeTN": null,
"Service": "",
"Type": "Incident",
"ContentCharset": "utf-8",
"DynamicField_TETest": null,
"Responsible": "root@localhost",
"SenderType": "customer",
"ResponsibleID": "1",
"SLA": "",
"MimeType": "text/plain",
"DynamicField_Combine": null,
"Subject": "test #3",
"InReplyTo": "",
"RealTillTimeNotUsed": "0",
"DynamicField_ScomService": null,
"CustomerID": "3333333333",
"TypeID": "1",
"MessageID": "",
"Priority": "3 normal",
"To": "Postmaster",
"DynamicField_SugarCRMCompanySelectedID": null,
"UntilTime": 0,
"EscalationUpdateTime": "0",
"CreatedBy": "3",
"Queue": "Postmaster",
"DynamicField_ITSMRepairStartTime": null,
"ToRealname": "Postmaster",
"State": "closed successful",
"SenderTypeID": "3",
"DynamicField_ZammadMigratorChangedOld": "1",
"Title": "test #3",
"DynamicField_ScomState": null,
"References": "",
"DynamicField_Department": null,
"ArticleType": "phone",
"StateType": "closed",
"FromRealname": "Betreuter Kunde",
"EscalationSolutionTime": "0",
"LockID": "1",
"TicketNumber": "20141121305000012",
"DynamicField_ITSMDecisionResult": null,
"Lock": "unlock",
"CreateTimeUnix": "1416525460",
"SLAID": null,
"DynamicField_ITSMCriticality": null,
"From": "\"Betreuter Kunde\" <kunde2@kunde.de>,"
}

View file

@ -61,6 +61,43 @@ RSpec.describe Import::OTRS::Article do
end
end
context 'content type with comma' do
let(:object_structure) { load_article_json('content_type_comma') }
let(:zammad_structure) {
{
created_by_id: '3',
updated_by_id: 1,
ticket_id: '730',
id: '3970',
body: 'test #3',
from: '"Betreuter Kunde" <kunde2@kunde.de>,',
to: 'Postmaster',
cc: '',
content_type: 'text/plain',
subject: 'test #3',
in_reply_to: '',
message_id: '',
references: '',
updated_at: '2014-11-21 00:21:08',
created_at: '2014-11-21 00:17:41',
type_id: 5,
internal: false,
sender_id: 2
}
}
it 'creates' do
expect(Import::OTRS::Article::AttachmentFactory).to receive(:import)
creates_with(zammad_structure)
end
it 'updates' do
expect(Import::OTRS::Article::AttachmentFactory).to receive(:import)
updates_with(zammad_structure)
end
end
context 'no content type' do
let(:object_structure) { load_article_json('no_content_type') }