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
|
||||
|
||||
# find attachments in upload cache
|
||||
attachments = []
|
||||
if form_id
|
||||
article.attachments = UploadCache.new(form_id).attachments
|
||||
attachments += UploadCache.new(form_id).attachments
|
||||
end
|
||||
|
||||
# set subtype of present
|
||||
article.preferences[:subtype] = subtype if subtype.present?
|
||||
|
||||
article.save!
|
||||
|
||||
# store inline attachments
|
||||
attachments_inline.each do |attachment|
|
||||
Store.add(
|
||||
object: 'Ticket::Article',
|
||||
o_id: article.id,
|
||||
attachments << {
|
||||
data: attachment[:data],
|
||||
filename: attachment[:filename],
|
||||
preferences: attachment[:preferences],
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
# add attachments as param
|
||||
|
@ -104,16 +98,21 @@ module CreatesTicketArticles
|
|||
raise Exceptions::UnprocessableEntity, "Invalid base64 for attachment with index '#{index}'"
|
||||
end
|
||||
|
||||
Store.add(
|
||||
object: 'Ticket::Article',
|
||||
o_id: article.id,
|
||||
attachments << {
|
||||
data: attachment_data,
|
||||
filename: attachment[:filename],
|
||||
preferences: preferences,
|
||||
)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
article.attachments = attachments
|
||||
|
||||
# set subtype of present
|
||||
article.preferences[:subtype] = subtype if subtype.present?
|
||||
|
||||
article.save!
|
||||
|
||||
# account time
|
||||
if time_unit.present?
|
||||
Ticket::TimeAccounting.create!(
|
||||
|
|
|
@ -44,10 +44,18 @@ returns
|
|||
|
||||
=begin
|
||||
|
||||
store attachments for this object
|
||||
store attachments for this object with store objects or hashes
|
||||
|
||||
item = Model.find(123)
|
||||
item.attachments = [ Store-Object1, Store-Object2 ]
|
||||
item.attachments = [
|
||||
Store-Object1,
|
||||
Store-Object2,
|
||||
{
|
||||
filename: 'test.txt',
|
||||
data: 'test',
|
||||
preferences: {},
|
||||
}
|
||||
]
|
||||
|
||||
=end
|
||||
|
||||
|
@ -118,14 +126,22 @@ For use in #search_index_attribute_lookup
|
|||
# store attachments
|
||||
article_store = []
|
||||
attachments_buffer.each do |attachment|
|
||||
article_store.push Store.add(
|
||||
data = {
|
||||
object: self.class.to_s,
|
||||
o_id: id,
|
||||
data: attachment.content,
|
||||
filename: attachment.filename,
|
||||
preferences: attachment.preferences,
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue