WIP issue #368 - OTRS tickets are created without an assigned customer user.

This commit is contained in:
Thorsten Eckel 2016-11-16 11:46:38 +01:00
parent 7ddc6da7b8
commit 24da432aec

View file

@ -632,13 +632,20 @@ module Import::OTRS
ticket_new.delete(:owner)
end
record['Articles'].each { |article|
# utf8 encode
_utf8_encode(article)
# lookup customers to create first
_article_based_customers(article)
}
# find customer
if ticket_new[:customer]
user = User.lookup(login: ticket_new[:customer].downcase)
ticket_new[:customer_id] = if user
user.id
else
1
_first_customer_id(record['Articles'])
end
ticket_new.delete(:customer)
else
@ -664,16 +671,6 @@ module Import::OTRS
end
end
# utf8 encode
record['Articles'].each { |article|
_utf8_encode(article)
}
# lookup customers to create first
record['Articles'].each { |article|
_article_based_customers(article)
}
record['Articles'].each do |article|
retries = 3
@ -1598,4 +1595,17 @@ module Import::OTRS
%w(ProcessManagementProcessID ProcessManagementActivityID ZammadMigratorChanged ZammadMigratorChangedOld)
end
def self._first_customer_id(articles)
user_id = 1
articles.each { |article|
next if article['sender'] != 'customer'
next if article['created_by_id'].to_i != 1
next if article['from'].empty?
user_id = article['created_by_id']
break
}
user_id
end
end