diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 00:08:47 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 00:08:47 +0300 |
commit | e4ea43b2b85ad5f3115f00220601eb719705139a (patch) | |
tree | 1888a43f802e45ebb8dfed59595a790807777c6f /app/mailers/application_mailer.rb | |
parent | 390582e118752426acf5cb25ec99103d312d891c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/mailers/application_mailer.rb')
-rw-r--r-- | app/mailers/application_mailer.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 00000000000..e0c95370072 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class ApplicationMailer < ActionMailer::Base + around_action :render_with_default_locale + + helper ApplicationHelper + helper MarkupHelper + + attr_accessor :current_user + helper_method :current_user, :can? + + default from: proc { default_sender_address.format } + default reply_to: proc { default_reply_to_address.format } + + def can? + Ability.allowed?(current_user, action, subject) + end + + private + + def render_with_default_locale(&block) + Gitlab::I18n.with_default_locale(&block) + end + + def default_sender_address + address = Mail::Address.new(Gitlab.config.gitlab.email_from) + address.display_name = Gitlab.config.gitlab.email_display_name + address + end + + def default_reply_to_address + address = Mail::Address.new(Gitlab.config.gitlab.email_reply_to) + address.display_name = Gitlab.config.gitlab.email_display_name + address + end +end |