<commit_before>class Notifier < ActionMailer::Base
  helper :notifier, :application

  default from: -> _ { Site.current.noreply_email }, charset: 'UTF-8'

  def profile_update(person, updates)
    @person = person
    @updates = updates
    mail(
      to:      Setting.get(:contact, :send_updates_to),
      subject: "Profile Update from #{person.name}."
    )
  end

  def email_update(person)
    @person = person
    mail(
      to:      Setting.get(:contact, :send_email_changes_to),
      subject: "#{person.name} Changed Email"
    )
  end

  def date_and_time_report
    mail(
      to:      Setting.get(:contact, :tech_support_email),
      subject: "Date & Time Incorrect"
    )
  end

  def friend_request(person, friend)
    @person = person
    @friend = friend
    mail(
      to:      "\"#{friend.name}\" <#{friend.email}>",
      subject: "Friend Request from #{person.name}"
    )
  end

  def membership_request(group, person)
    @group = group
    @person = person
    unless (to = group.admins.select { |p| p.email.to_s.any? }.map { |p| "#{p.name} <#{p.email}>" }).any?
      unless (to = Admin.to_a.select { |a| a.manage_updates? }.map { |a| "#{a.person.name} <#{a.person.email}>" }).any?
        to = Admin.where(super_admin: true).map { |a| a.person.email }
      end
    end
    mail(
      to:      to,
      from:    person.email.to_s.any? ? "\"#{person.name}\" <#{person.email}>" : Site.current.noreply_email,
      subject: "Request to Join Group from #{person.name}"
    )
  end

  def full_message(to, msg, id_and_code=nil)
    @to          = to
    @msg         = msg
    @id_and_code = id_and_code
    h = {'Reply-To' => msg.email_reply_to(to)}
    if msg.group<commit_msg>Fix bug sending notification of group membership request.<commit_after>class Notifier < ActionMailer::Base
  helper :notifier, :application

  default from: -> _ { Site.current.noreply_email }, charset: 'UTF-8'

  def profile_update(person, updates)
    @person = person
    @updates = updates
    mail(
      to:      Setting.get(:contact, :send_updates_to),
      subject: "Profile Update from #{person.name}."
    )
  end

  def email_update(person)
    @person = person
    mail(
      to:      Setting.get(:contact, :send_email_changes_to),
      subject: "#{person.name} Changed Email"
    )
  end

  def date_and_time_report
    mail(
      to:      Setting.get(:contact, :tech_support_email),
      subject: "Date & Time Incorrect"
    )
  end

  def friend_request(person, friend)
    @person = person
    @friend = friend
    mail(
      to:      "\"#{friend.name}\" <#{friend.email}>",
      subject: "Friend Request from #{person.name}"
    )
  end

  def membership_request(group, person)
    @group = group
    @person = person
    unless (to = group.admins.select { |p| p.email.to_s.any? }.map { |p| "#{p.name} <#{p.email}>" }).any?
      unless (to = Admin.all.select { |a| a.manage_updates? }.map { |a| "#{a.person.name} <#{a.person.email}>" }).any?
        to = Admin.where(super_admin: true).map { |a| a.person.email }
      end
    end
    mail(
      to:      to,
      from:    person.email.to_s.any? ? "\"#{person.name}\" <#{person.email}>" : Site.current.noreply_email,
      subject: "Request to Join Group from #{person.name}"
    )
  end

  def full_message(to, msg, id_and_code=nil)
    @to          = to
    @msg         = msg
    @id_and_code = id_and_code
    h = {'Reply-To' => msg.email_reply_to(to)}
    if msg.group
{'fraction_non_alphanumeric': 0.14955163436505642, 'fraction_numerical': 0.0005785363031530228, 'mean_word_length': 2.5908618899273104, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '3704736', 'n_tokens_mistral': 1212, 'n_tokens_neox': 1197, 'n_words': 274}