BigW Consortium Gitlab

base_mailer.rb 931 Bytes
Newer Older
Douwe Maan committed
1
class BaseMailer < ActionMailer::Base
2 3
  include Gitlab::CurrentSettings

4 5
  around_action :render_with_default_locale

6
  helper ApplicationHelper
7
  helper MarkupHelper
8 9

  attr_accessor :current_user
10
  helper_method :current_user, :can?, :current_application_settings
11

12 13
  default from:     proc { default_sender_address.format }
  default reply_to: proc { default_reply_to_address.format }
14 15

  def can?
16
    Ability.allowed?(current_user, action, subject)
17 18 19 20
  end

  private

21 22 23 24
  def render_with_default_locale(&block)
    Gitlab::I18n.with_default_locale(&block)
  end

25 26 27 28 29 30 31 32 33 34 35 36
  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