<commit_before># frozen_string_literal: true

class ConversationsController < ApplicationController
  before_action :authenticate_user!

  def new
    @other_users = User.all.reject { |u| u == current_user }.collect { |p| [p.name, p.id] }
  end

  def create
    recipients = User.where(id: conversation_params[:recipients])
    conversation = current_user
                   .send_message(recipients,
                                 conversation_params[:body],
                                 conversation_params[:subject])
                   .conversation
    flash[:success] = 'Your message was successfully sent!'
    redirect_to conversation_path(conversation)
  end

  def show
    @receipts = conversation.receipts_for(current_user)
    # mark conversation as read
    conversation.mark_as_read(current_user)
  end

  def reply
    current_user.reply_to_conversation(conversation, message_params[:body])
    flash[:notice] = 'Your reply message was successfully sent!'
    redirect_to conversation_path(conversation)<commit_msg>refactor new method<commit_after># frozen_string_literal: true

class ConversationsController < ApplicationController
  before_action :authenticate_user!

  def new
    @other_users = User.where.not(id: current_user.id).pluck(:name, :id)
  end

  def create
    recipients = User.where(id: conversation_params[:recipients])
    conversation = current_user
                   .send_message(recipients,
                                 conversation_params[:body],
                                 conversation_params[:subject])
                   .conversation
    flash[:success] = 'Your message was successfully sent!'
    redirect_to conversation_path(conversation)
  end

  def show
    @receipts = conversation.receipts_for(current_user)
    # mark conversation as read
    conversation.mark_as_read(current_user)
  end

  def reply
    current_user.reply_to_conversation(conversation, message_params[:body])
    flash[:notice] = 'Your reply message was successfully sent!'
    redirect_to conversation_path(conversation)
{'fraction_non_alphanumeric': 0.07763221737020863, 'fraction_numerical': 0.0, 'mean_word_length': 3.1157684630738522, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6260495', 'n_tokens_mistral': 563, 'n_tokens_neox': 547, 'n_words': 122}