2018-08-15 17:45:57 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-19 14:00:41 -04:00
|
|
|
module Emails
|
|
|
|
module Projects
|
2015-09-29 09:37:50 -04:00
|
|
|
def project_was_moved_email(project_id, user_id, old_path_with_namespace)
|
2015-03-27 07:58:23 -04:00
|
|
|
@current_user = @user = User.find user_id
|
2013-06-22 03:56:51 -04:00
|
|
|
@project = Project.find project_id
|
2017-06-29 13:06:35 -04:00
|
|
|
@target_url = project_url(@project)
|
2015-09-29 09:37:50 -04:00
|
|
|
@old_path_with_namespace = old_path_with_namespace
|
2019-09-30 08:06:01 -04:00
|
|
|
mail(to: @user.notification_email_for(@project.group),
|
2013-11-08 10:04:36 -05:00
|
|
|
subject: subject("Project was moved"))
|
2015-04-10 10:37:02 -04:00
|
|
|
end
|
|
|
|
|
2016-06-14 10:31:03 -04:00
|
|
|
def project_was_exported_email(current_user, project)
|
|
|
|
@project = project
|
2019-09-30 08:06:01 -04:00
|
|
|
mail(to: current_user.notification_email_for(project.group),
|
2016-06-14 10:31:03 -04:00
|
|
|
subject: subject("Project was exported"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_was_not_exported_email(current_user, project, errors)
|
|
|
|
@project = project
|
|
|
|
@errors = errors
|
2019-09-30 08:06:01 -04:00
|
|
|
mail(to: current_user.notification_email_for(@project.group),
|
2016-06-14 10:31:03 -04:00
|
|
|
subject: subject("Project export error"))
|
|
|
|
end
|
|
|
|
|
2018-11-19 10:03:58 -05:00
|
|
|
def repository_cleanup_success_email(project, user)
|
|
|
|
@project = project
|
|
|
|
@user = user
|
|
|
|
|
2019-09-30 08:06:01 -04:00
|
|
|
mail(to: user.notification_email_for(project.group), subject: subject("Project cleanup has completed"))
|
2018-11-19 10:03:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def repository_cleanup_failure_email(project, user, error)
|
|
|
|
@project = project
|
|
|
|
@user = user
|
|
|
|
@error = error
|
|
|
|
|
2019-09-30 08:06:01 -04:00
|
|
|
mail(to: user.notification_email_for(project.group), subject: subject("Project cleanup failure"))
|
2018-11-19 10:03:58 -05:00
|
|
|
end
|
|
|
|
|
2016-05-06 08:16:53 -04:00
|
|
|
def repository_push_email(project_id, opts = {})
|
2015-11-21 14:54:19 -05:00
|
|
|
@message =
|
2016-05-06 08:16:53 -04:00
|
|
|
Gitlab::Email::Message::RepositoryPush.new(self, project_id, opts)
|
2015-11-18 04:13:34 -05:00
|
|
|
|
2015-11-23 15:25:49 -05:00
|
|
|
# used in notify layout
|
|
|
|
@target_url = @message.target_url
|
2016-05-12 11:06:14 -04:00
|
|
|
@project = Project.find(project_id)
|
|
|
|
@diff_notes_disabled = true
|
2015-12-19 14:04:40 -05:00
|
|
|
|
|
|
|
add_project_headers
|
|
|
|
headers['X-GitLab-Author'] = @message.author_username
|
2015-11-23 15:25:49 -05:00
|
|
|
|
2020-01-09 13:07:52 -05:00
|
|
|
mail(from: sender(@message.author_id, send_from_user_email: @message.send_from_committer_email?),
|
2015-11-21 14:54:19 -05:00
|
|
|
reply_to: @message.reply_to,
|
|
|
|
subject: @message.subject)
|
2013-12-17 07:45:55 -05:00
|
|
|
end
|
2020-03-19 20:09:29 -04:00
|
|
|
|
2020-11-03 13:09:22 -05:00
|
|
|
def prometheus_alert_fired_email(project, user, alert)
|
|
|
|
@project = project
|
|
|
|
@alert = alert.present
|
2021-12-08 22:13:31 -05:00
|
|
|
@incident = alert.issue
|
2020-03-19 20:09:29 -04:00
|
|
|
|
2021-07-29 17:10:10 -04:00
|
|
|
add_project_headers
|
|
|
|
add_alert_headers
|
|
|
|
|
2020-09-22 08:09:39 -04:00
|
|
|
subject_text = "Alert: #{@alert.email_title}"
|
2020-03-19 20:09:29 -04:00
|
|
|
mail(to: user.notification_email_for(@project.group), subject: subject(subject_text))
|
|
|
|
end
|
2021-07-29 17:10:10 -04:00
|
|
|
|
2022-05-09 05:08:47 -04:00
|
|
|
def inactive_project_deletion_warning_email(project, user, deletion_date)
|
|
|
|
@project = project
|
|
|
|
@user = user
|
|
|
|
@deletion_date = deletion_date
|
|
|
|
subject_text = "Action required: Project #{project.name} is scheduled to be deleted on " \
|
|
|
|
"#{deletion_date} due to inactivity"
|
|
|
|
|
|
|
|
mail(to: user.notification_email_for(project.group),
|
|
|
|
subject: subject(subject_text)) do |format|
|
|
|
|
format.html { render layout: 'mailer' }
|
|
|
|
format.text { render layout: 'mailer' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-07-29 17:10:10 -04:00
|
|
|
private
|
|
|
|
|
|
|
|
def add_alert_headers
|
|
|
|
return unless @alert
|
|
|
|
|
|
|
|
headers['X-GitLab-Alert-ID'] = @alert.id
|
|
|
|
headers['X-GitLab-Alert-IID'] = @alert.iid
|
|
|
|
headers['X-GitLab-NotificationReason'] = "alert_#{@alert.state}"
|
|
|
|
|
|
|
|
add_incident_headers
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_incident_headers
|
2021-12-08 22:13:31 -05:00
|
|
|
return unless @incident
|
2021-07-29 17:10:10 -04:00
|
|
|
|
2021-12-08 22:13:31 -05:00
|
|
|
headers['X-GitLab-Incident-ID'] = @incident.id
|
|
|
|
headers['X-GitLab-Incident-IID'] = @incident.iid
|
2021-07-29 17:10:10 -04:00
|
|
|
end
|
2013-03-19 14:00:41 -04:00
|
|
|
end
|
|
|
|
end
|
2019-09-13 09:26:31 -04:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
Emails::Projects.prepend_mod_with('Emails::Projects')
|