2015-08-19 15:51:42 -04:00
|
|
|
class BaseMailer < ActionMailer::Base
|
2015-08-19 15:35:08 -04:00
|
|
|
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 self.delay
|
|
|
|
delay_for(2.seconds)
|
|
|
|
end
|
|
|
|
|
|
|
|
def can?
|
2015-08-19 17:58:41 -04:00
|
|
|
Ability.abilities.allowed?(current_user, action, subject)
|
2015-08-19 15:35:08 -04:00
|
|
|
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
|