<commit_before>class PrivateMessenger
  include Rails.application.routes.url_helpers

  def initialize(recipient, message, message_object)
    @message = message
    @recipient = recipient
    @message_object = message_object
    send(@message)
  end

  def reminder
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.event.owner
    @message_body = reminder_message_body
  end

  def group_reminder
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.event.owner
    @message_body = reminder_message_body
  end

  def invitation
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.event.owner
    @message_body = invitation_message_body
  end

  def group_invitation
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.event.owner
    @message_body = group_invitation_message_body
  end

  def deliver
    if @recipient.yammer_user_id
      send_user_message
    else
      send_group_message
    end
  end

  private

  def reminder_message_body
    <<-BODY.strip_heredoc
      Reminder: Help out #{@event.owner.name} by voting on "#{@event.name}".

      Please click this link to view the options and vote: #{event_url(@event)}

      *This poll was sent using Sched.do. Create your own polls for free at #{root_url}
    BODY
  end

  def invitation_message_body
     <<-BODY.strip_heredoc
      #{@recipient.name}, I am planning "#{@event.name}" and I need your help.

      Please click this link to view the options and vote: #{event_url(@event)}


      Thanks in advance!<commit_msg>Send Yammer PMs from the invitation sender<commit_after>class PrivateMessenger
  include Rails.application.routes.url_helpers

  def initialize(recipient, message, message_object)
    @message = message
    @recipient = recipient
    @message_object = message_object
    send(@message)
  end

  def reminder
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.event.owner
    @message_body = reminder_message_body
  end

  def group_reminder
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.event.owner
    @message_body = reminder_message_body
  end

  def invitation
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.sender
    @message_body = invitation_message_body
  end

  def group_invitation
    @invitation = @message_object
    @event = @invitation.event
    @sender = @invitation.sender
    @message_body = group_invitation_message_body
  end

  def deliver
    if @recipient.yammer_user_id
      send_user_message
    else
      send_group_message
    end
  end

  private

  def reminder_message_body
    <<-BODY.strip_heredoc
      Reminder: Help out #{@event.owner.name} by voting on "#{@event.name}".

      Please click this link to view the options and vote: #{event_url(@event)}

      *This poll was sent using Sched.do. Create your own polls for free at #{root_url}
    BODY
  end

  def invitation_message_body
     <<-BODY.strip_heredoc
      #{@recipient.name}, I am planning "#{@event.name}" and I need your help.

      Please click this link to view the options and vote: #{event_url(@event)}


      Thanks in advance!
{'fraction_non_alphanumeric': 0.08079589990955682, 'fraction_numerical': 0.0, 'mean_word_length': 3.3035019455252916, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1858474', 'n_tokens_mistral': 1045, 'n_tokens_neox': 998, 'n_words': 275}