Fixes #2991 - SMTP-Attachments missing when using the API under high load.
This commit is contained in:
parent
408af2dae4
commit
c3468d3c39
2 changed files with 36 additions and 21 deletions
|
@ -56,24 +56,18 @@ module CreatesTicketArticles
|
||||||
end
|
end
|
||||||
|
|
||||||
# find attachments in upload cache
|
# find attachments in upload cache
|
||||||
|
attachments = []
|
||||||
if form_id
|
if form_id
|
||||||
article.attachments = UploadCache.new(form_id).attachments
|
attachments += UploadCache.new(form_id).attachments
|
||||||
end
|
end
|
||||||
|
|
||||||
# set subtype of present
|
|
||||||
article.preferences[:subtype] = subtype if subtype.present?
|
|
||||||
|
|
||||||
article.save!
|
|
||||||
|
|
||||||
# store inline attachments
|
# store inline attachments
|
||||||
attachments_inline.each do |attachment|
|
attachments_inline.each do |attachment|
|
||||||
Store.add(
|
attachments << {
|
||||||
object: 'Ticket::Article',
|
|
||||||
o_id: article.id,
|
|
||||||
data: attachment[:data],
|
data: attachment[:data],
|
||||||
filename: attachment[:filename],
|
filename: attachment[:filename],
|
||||||
preferences: attachment[:preferences],
|
preferences: attachment[:preferences],
|
||||||
)
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
# add attachments as param
|
# add attachments as param
|
||||||
|
@ -104,16 +98,21 @@ module CreatesTicketArticles
|
||||||
raise Exceptions::UnprocessableEntity, "Invalid base64 for attachment with index '#{index}'"
|
raise Exceptions::UnprocessableEntity, "Invalid base64 for attachment with index '#{index}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
Store.add(
|
attachments << {
|
||||||
object: 'Ticket::Article',
|
|
||||||
o_id: article.id,
|
|
||||||
data: attachment_data,
|
data: attachment_data,
|
||||||
filename: attachment[:filename],
|
filename: attachment[:filename],
|
||||||
preferences: preferences,
|
preferences: preferences,
|
||||||
)
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
article.attachments = attachments
|
||||||
|
|
||||||
|
# set subtype of present
|
||||||
|
article.preferences[:subtype] = subtype if subtype.present?
|
||||||
|
|
||||||
|
article.save!
|
||||||
|
|
||||||
# account time
|
# account time
|
||||||
if time_unit.present?
|
if time_unit.present?
|
||||||
Ticket::TimeAccounting.create!(
|
Ticket::TimeAccounting.create!(
|
||||||
|
|
|
@ -44,10 +44,18 @@ returns
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
store attachments for this object
|
store attachments for this object with store objects or hashes
|
||||||
|
|
||||||
item = Model.find(123)
|
item = Model.find(123)
|
||||||
item.attachments = [ Store-Object1, Store-Object2 ]
|
item.attachments = [
|
||||||
|
Store-Object1,
|
||||||
|
Store-Object2,
|
||||||
|
{
|
||||||
|
filename: 'test.txt',
|
||||||
|
data: 'test',
|
||||||
|
preferences: {},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
@ -118,14 +126,22 @@ For use in #search_index_attribute_lookup
|
||||||
# store attachments
|
# store attachments
|
||||||
article_store = []
|
article_store = []
|
||||||
attachments_buffer.each do |attachment|
|
attachments_buffer.each do |attachment|
|
||||||
article_store.push Store.add(
|
data = {
|
||||||
object: self.class.to_s,
|
object: self.class.to_s,
|
||||||
o_id: id,
|
o_id: id,
|
||||||
data: attachment.content,
|
|
||||||
filename: attachment.filename,
|
|
||||||
preferences: attachment.preferences,
|
|
||||||
created_by_id: created_by_id,
|
created_by_id: created_by_id,
|
||||||
)
|
}
|
||||||
|
if attachment.is_a?(Store)
|
||||||
|
data[:data] = attachment.content
|
||||||
|
data[:filename] = attachment.filename
|
||||||
|
data[:preferences] = attachment.preferences
|
||||||
|
else
|
||||||
|
data[:data] = attachment[:data]
|
||||||
|
data[:filename] = attachment[:filename]
|
||||||
|
data[:preferences] = attachment[:preferences]
|
||||||
|
end
|
||||||
|
|
||||||
|
article_store.push Store.add(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue