summaryrefslogtreecommitdiff
path: root/app/mailers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 18:07:43 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-01 18:07:43 +0000
commitad1e76fb4d1392c890c8b5e218a256a416d5a50b (patch)
tree51e5541bb1f1a799e288701bc1170a3b1a9a7393 /app/mailers
parent8b1036168b0d395c379cbbaf457e256860147405 (diff)
downloadgitlab-ce-ad1e76fb4d1392c890c8b5e218a256a416d5a50b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/emails/issues.rb13
-rw-r--r--app/mailers/emails/shared.rb20
-rw-r--r--app/mailers/emails/work_items.rb4
-rw-r--r--app/mailers/notify.rb1
4 files changed, 26 insertions, 12 deletions
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb
index 58843435fa0..e053fc0453c 100644
--- a/app/mailers/emails/issues.rb
+++ b/app/mailers/emails/issues.rb
@@ -100,18 +100,7 @@ module Emails
end
def issues_csv_email(user, project, csv_data, export_status)
- @project = project
- @count = export_status.fetch(:rows_expected)
- @written_count = export_status.fetch(:rows_written)
- @truncated = export_status.fetch(:truncated)
- @size_limit = ActiveSupport::NumberHelper
- .number_to_human_size(ExportCsv::BaseService::TARGET_FILESIZE)
-
- filename = "#{project.full_path.parameterize}_issues_#{Date.today.iso8601}.csv"
- attachments[filename] = { content: csv_data, mime_type: 'text/csv' }
- email_with_layout(
- to: user.notification_email_for(@project.group),
- subject: subject("Exported issues"))
+ csv_email(user, project, csv_data, export_status, 'issues')
end
private
diff --git a/app/mailers/emails/shared.rb b/app/mailers/emails/shared.rb
new file mode 100644
index 00000000000..09876c0960a
--- /dev/null
+++ b/app/mailers/emails/shared.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module Emails
+ module Shared
+ def csv_email(user, project, csv_data, export_status, type)
+ @project = project
+ @count = export_status.fetch(:rows_expected)
+ @written_count = export_status.fetch(:rows_written)
+ @truncated = export_status.fetch(:truncated)
+ @size_limit = ActiveSupport::NumberHelper
+ .number_to_human_size(ExportCsv::BaseService::TARGET_FILESIZE)
+
+ filename = "#{project.full_path.parameterize}_#{type}_#{Date.today.iso8601}.csv"
+ attachments[filename] = { content: csv_data, mime_type: 'text/csv' }
+ email_with_layout(
+ to: user.notification_email_for(@project.group),
+ subject: subject("Exported #{type.humanize.downcase}"))
+ end
+ end
+end
diff --git a/app/mailers/emails/work_items.rb b/app/mailers/emails/work_items.rb
index fe669fdbedc..a243158d82f 100644
--- a/app/mailers/emails/work_items.rb
+++ b/app/mailers/emails/work_items.rb
@@ -11,5 +11,9 @@ module Emails
to: @user.notification_email_for(@project),
subject: subject('Imported work items'))
end
+
+ def export_work_items_csv_email(user, project, csv_data, export_status)
+ csv_email(user, project, csv_data, export_status, 'work_items')
+ end
end
end
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index 0465887cdc6..2d6b2a3099c 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -7,6 +7,7 @@ class Notify < ApplicationMailer
include ReminderEmailsHelper
include IssuablesHelper
+ include Emails::Shared
include Emails::Issues
include Emails::MergeRequests
include Emails::Notes