<commit_before>class EmailRejectionMailer < ActionMailer::Base
  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 rejection(reason, original_raw, can_retry = false)
    @reason = reason
    @original_message = Mail::Message.new(original_raw)

    headers = {
      to: @original_message.from,
      subject: "[Rejected] #{@original_message.subject}"
    }

    headers['Message-ID'] = SecureRandom.hex
    headers['In-Reply-To'] = @original_message.message_id
    headers['References'] = @original_message.message_id

    headers['Reply-To'] = @original_message.to.first if can_retry

    mail(headers)
  end

  def can?
    Ability.abilities.allowed?(user, action, subject)
  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<commit_msg>Fix BaseMailer.<commit_after>class BaseMailer < ActionMailer::Base
  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?
    Ability.abilities.allowed?(user, action, subject)
  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
{'fraction_non_alphanumeric': 0.08522212148685404, 'fraction_numerical': 0.0009066183136899365, 'mean_word_length': 4.3180722891566266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7526507', 'n_tokens_mistral': 721, 'n_tokens_neox': 693, 'n_words': 123}