2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
module Emails
|
|
|
|
module Projects
|
2015-10-24 18:46:33 +05:30
|
|
|
def project_was_moved_email(project_id, user_id, old_path_with_namespace)
|
2015-04-26 12:48:37 +05:30
|
|
|
@current_user = @user = User.find user_id
|
2014-09-02 18:07:02 +05:30
|
|
|
@project = Project.find project_id
|
2017-09-10 17:25:29 +05:30
|
|
|
@target_url = project_url(@project)
|
2015-10-24 18:46:33 +05:30
|
|
|
@old_path_with_namespace = old_path_with_namespace
|
2019-12-21 20:55:43 +05:30
|
|
|
mail(to: @user.notification_email_for(@project.group),
|
2014-09-02 18:07:02 +05:30
|
|
|
subject: subject("Project was moved"))
|
|
|
|
end
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
def project_was_exported_email(current_user, project)
|
|
|
|
@project = project
|
2019-12-21 20:55:43 +05:30
|
|
|
mail(to: current_user.notification_email_for(project.group),
|
2016-06-22 15:30:34 +05:30
|
|
|
subject: subject("Project was exported"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def project_was_not_exported_email(current_user, project, errors)
|
|
|
|
@project = project
|
|
|
|
@errors = errors
|
2019-12-21 20:55:43 +05:30
|
|
|
mail(to: current_user.notification_email_for(@project.group),
|
2016-06-22 15:30:34 +05:30
|
|
|
subject: subject("Project export error"))
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
def repository_cleanup_success_email(project, user)
|
|
|
|
@project = project
|
|
|
|
@user = user
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
mail(to: user.notification_email_for(project.group), subject: subject("Project cleanup has completed"))
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def repository_cleanup_failure_email(project, user, error)
|
|
|
|
@project = project
|
|
|
|
@user = user
|
|
|
|
@error = error
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
mail(to: user.notification_email_for(project.group), subject: subject("Project cleanup failure"))
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
def repository_push_email(project_id, opts = {})
|
2015-12-23 02:04:40 +05:30
|
|
|
@message =
|
2016-06-02 11:05:42 +05:30
|
|
|
Gitlab::Email::Message::RepositoryPush.new(self, project_id, opts)
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
# used in notify layout
|
|
|
|
@target_url = @message.target_url
|
2016-06-02 11:05:42 +05:30
|
|
|
@project = Project.find(project_id)
|
|
|
|
@diff_notes_disabled = true
|
2016-01-29 22:53:50 +05:30
|
|
|
|
|
|
|
add_project_headers
|
|
|
|
headers['X-GitLab-Author'] = @message.author_username
|
2015-12-23 02:04:40 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
mail(from: sender(@message.author_id, send_from_user_email: @message.send_from_committer_email?),
|
2015-12-23 02:04:40 +05:30
|
|
|
reply_to: @message.reply_to,
|
|
|
|
subject: @message.subject)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
def prometheus_alert_fired_email(project, user, alert)
|
|
|
|
@project = project
|
|
|
|
@alert = alert.present
|
2022-01-26 12:08:38 +05:30
|
|
|
@incident = alert.issue
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
add_project_headers
|
|
|
|
add_alert_headers
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
subject_text = "Alert: #{@alert.email_title}"
|
2020-04-22 19:07:51 +05:30
|
|
|
mail(to: user.notification_email_for(@project.group), subject: subject(subject_text))
|
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
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"
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
email_with_layout(
|
|
|
|
to: user.notification_email_for(project.group),
|
|
|
|
subject: subject(subject_text))
|
2022-07-16 23:28:13 +05:30
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
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
|
2022-01-26 12:08:38 +05:30
|
|
|
return unless @incident
|
2021-10-27 15:23:28 +05:30
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
headers['X-GitLab-Incident-ID'] = @incident.id
|
|
|
|
headers['X-GitLab-Incident-IID'] = @incident.iid
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
Emails::Projects.prepend_mod_with('Emails::Projects')
|