<commit_before>class Emailer < ActionMailer::Base
  include ActionController::UrlWriter # Allows us to generate URLs
  include ActionView::Helpers::TextHelper
  concerned_with :receive

  ANSWER_LINE = '-----------------------------==-----------------------------'

  def confirm_email(user)
    defaults
    recipients    user.email
    subject       'Get started with Teambox!'
    body          :user => user, :login_link => confirm_email_user_url(user, :token => user.login_token)
  end

  def reset_password(user)
    defaults
    recipients    user.email
    subject       'Your password has successfully been reset!'
    body          :user => user
  end

  def forgot_password(reset_password)
    defaults
    recipients    reset_password.email
    subject       'Password retrieval for Teambox'
    body          :user => reset_password.user, :url => reset_password_url(reset_password.reset_code)
  end

  def project_invitation(invitation)
    defaults
    recipients    invitation.email
    subject       "#{invitation.user.name} shared [#{invitation.project.name}] with you"
    body          :referral => invitation.user, :project => invitation.project, :invitation => invitation
  end

  def signup_invitation(invitation)
    defaults
    recipients    invitation.email
    subject       "#{invitation.user.name} shared [#{invitation.project.name}] with you"
    body          :referral => invitation.user, :project => invitation.project, :invitation => invitation
  end

  def notify_comment(user, project, comment)
    defaults
    recipients    user.email
    from          from_address(project.permalink)
    if APP_CONFIG['allow_incoming_email']
      reply_to      from_address("#{project.permalink}")
    end
    subject       "[#{project.permalink}] #{truncate(comment.body, :length => 20)}"
    body          :project => project, :comment => comment
  end

  def notify_conversation(user, project, conversation)
    defaults
    recipients    user.email
    from          from_address(project.permalink)
    if APP_CONFIG['allow_incoming_email']
      reply_to      from_address("#{project.permalink}+conversation+#{conversation.id}")
    end
    subject       "[#{project.permalink}] #{conversation.name}"
    body          :project => project, :conversation => conversation
  end

  def notify_task(user, project, task)
    defaults
    recipients    user.email
    from          from_address(project.permalink)
    if APP_CONFIG['allow_incoming_email']
      reply_to      from_address("#{project.permalink}+task+#{task.id}")
    end
    subject       "[#{project.permalink}] #{task.name}"
    body          :project => project, :task => task, :task_list => task.task_list
  end

  def notify_task_list(user, project, task_list)
    defaults
    recipients    user.email
    from          from_address(project.permalink)
    if APP_CONFIG['allow_incoming_email']<commit_msg>Setting the from address to the posting user for notifications<commit_after>class Emailer < ActionMailer::Base
  include ActionController::UrlWriter # Allows us to generate URLs
  include ActionView::Helpers::TextHelper
  concerned_with :receive

  ANSWER_LINE = '-----------------------------==-----------------------------'

  def confirm_email(user)
    defaults
    recipients    user.email
    subject       'Get started with Teambox!'
    body          :user => user, :login_link => confirm_email_user_url(user, :token => user.login_token)
  end

  def reset_password(user)
    defaults
    recipients    user.email
    subject       'Your password has successfully been reset!'
    body          :user => user
  end

  def forgot_password(reset_password)
    defaults
    recipients    reset_password.email
    subject       'Password retrieval for Teambox'
    body          :user => reset_password.user, :url => reset_password_url(reset_password.reset_code)
  end

  def project_invitation(invitation)
    defaults
    recipients    invitation.email
    from          invitation.user.email
    subject       "#{invitation.user.name} shared [#{invitation.project.name}] with you"
    body          :referral => invitation.user, :project => invitation.project, :invitation => invitation
  end

  def signup_invitation(invitation)
    defaults
    recipients    invitation.email
    subject       "#{invitation.user.name} shared [#{invitation.project.name}] with you"
    body          :referral => invitation.user, :project => invitation.project, :invitation => invitation
  end

  def notify_comment(user, project, comment)
    defaults
    recipients    user.email
    from          comment.user.email
    if APP_CONFIG['allow_incoming_email']
      reply_to      from_address("#{project.permalink}")
    end
    subject       "[#{project.permalink}] #{truncate(comment.body, :length => 20)}"
    body          :project => project, :comment => comment
  end

  def notify_conversation(user, project, conversation)
    defaults
    recipients    user.email
    from          conversation.comments.last.user.email
    if APP_CONFIG['allow_incoming_email']
      reply_to      from_address("#{project.permalink}+conversation+#{conversation.id}")
    end
    subject       "[#{project.permalink}] #{conversation.name}"
    body          :project => project, :conversation => conversation
  end

  def notify_task(user, project, task)
    defaults
    recipients    user.email
    from          task.comments.last.user.email
    if APP_CONFIG['allow_incoming_email']
      reply_to      from_address("#{project.permalink}+task+#{task.id}")
    end
    subject       "[#{project.permalink}] #{task.name}"
    body          :project => project, :task => task, :task_list => task.task_list
  end

  def notify_task_list(user, project, task_list)
    defaults
    recipients    user.email
    from          task_list.comments.last.user.email
    if APP_CONFIG['allow_incoming_email']
{'fraction_non_alphanumeric': 0.11422743498215196, 'fraction_numerical': 0.000679925208227095, 'mean_word_length': 2.798579728857327, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '6572874', 'n_tokens_mistral': 1658, 'n_tokens_neox': 1644, 'n_words': 384}