<commit_before>class InvitationsController < ApplicationController
  before_filter :login_required, :except => :accept

  def index
  end

  def create
    emails = params[:invitations][:emails].split(',')
    user_role = params[:invitations][:user_role]
    emails.each do |email|
      unless email.blank?
        invitation = current_user.invite(email, user_role,
                                       current_group)
        Jobs::Mailer.async.on_new_invitation(invitation.id).commit!
      end
    end
    flash[:notice] = t("flash_notice", :scope => "invitations.create")
    redirect_to :back
  end

  def accept
    @invitation = Invitation.find(params[:id])
    @group = @invitation.group
    if @invitation.group.is_email_only_signup? && @invitation.state?(:pending) &&
        !logged_in?
      redirect_to new_user_path(:invitation_id => params[:id])
    elsif @invitation.state?(:pending) && logged_in?
      @invitation.connect!
    end
    @invitation.send(params[:step]) if params[:step]
    if @invitation.state?(:follow_suggestions)
      redirect_to '/'
    end
  end

  def revoke
    invitation = Invitation.find(params[:id])
    current_user.revoke_invite(invitation)
    redirect_to :back
  end<commit_msg>don't send invitation if user already is a member<commit_after>class InvitationsController < ApplicationController
  before_filter :login_required, :except => :accept

  def index
  end

  def create
    emails = params[:invitations][:emails].split(',')
    user_role = params[:invitations][:user_role]
    emails.each do |email|
      invited_user = User.where(:email => email)
      unless email.blank? ||
          (invited_user && current_group.is_member?(invited_user))
        invitation = current_user.invite(email, user_role,
                                       current_group)
        Jobs::Mailer.async.on_new_invitation(invitation.id).commit!
      end
    end
    flash[:notice] = t("flash_notice", :scope => "invitations.create")
    redirect_to :back
  end

  def accept
    @invitation = Invitation.find(params[:id])
    @group = @invitation.group
    if @invitation.group.is_email_only_signup? && @invitation.state?(:pending) &&
        !logged_in?
      redirect_to new_user_path(:invitation_id => params[:id])
    elsif @invitation.state?(:pending) && logged_in?
      @invitation.connect!
    end
    @invitation.send(params[:step]) if params[:step]
    if @invitation.state?(:follow_suggestions)
      redirect_to '/'
    end
  end

  def revoke
    invitation = Invitation.find(params[:id])
    current_user.revoke_invite(invitation)
    redirect_to :back
  end
{'fraction_non_alphanumeric': 0.11710677382319173, 'fraction_numerical': 0.0, 'mean_word_length': 3.2852459016393443, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6528008', 'n_tokens_mistral': 817, 'n_tokens_neox': 813, 'n_words': 150}