7e6f6e1603
Enables frozens string for the following: * lib/gitlab/conflict/**/*.rb * lib/gitlab/cross_project_access/**/*.rb * lib/gitlab/cycle_analytics/**/*.rb * lib/gitlab/data_builder/**/*.rb * lib/gitlab/database/**/*.rb * lib/gitlab/dependency_linker/**/*.rb * lib/gitlab/diff/**/*.rb * lib/gitlab/downtime_check/**/*.rb * lib/gitlab/email/**/*.rb * lib/gitlab/etag_caching/**/*.rb Partially addresses gitlab-org/gitlab-ce#47424.
37 lines
826 B
Ruby
37 lines
826 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module Email
|
|
class AttachmentUploader
|
|
attr_accessor :message
|
|
|
|
def initialize(message)
|
|
@message = message
|
|
end
|
|
|
|
def execute(project)
|
|
attachments = []
|
|
|
|
message.attachments.each do |attachment|
|
|
tmp = Tempfile.new("gitlab-email-attachment")
|
|
begin
|
|
File.open(tmp.path, "w+b") { |f| f.write attachment.body.decoded }
|
|
|
|
file = {
|
|
tempfile: tmp,
|
|
filename: attachment.filename,
|
|
content_type: attachment.content_type
|
|
}
|
|
|
|
link = UploadService.new(project, file).execute
|
|
attachments << link if link
|
|
ensure
|
|
tmp.close!
|
|
end
|
|
end
|
|
|
|
attachments
|
|
end
|
|
end
|
|
end
|
|
end
|