BigW Consortium Gitlab

base_mailer.rb 769 Bytes
Newer Older
Douwe Maan committed
1
class BaseMailer < ActionMailer::Base
2 3 4 5 6 7 8 9 10 11
  add_template_helper ApplicationHelper
  add_template_helper GitlabMarkdownHelper

  attr_accessor :current_user
  helper_method :current_user, :can?

  default from:     Proc.new { default_sender_address.format }
  default reply_to: Proc.new { default_reply_to_address.format }

  def can?
12
    Ability.allowed?(current_user, action, subject)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
  end

  private

  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