<commit_before># frozen_string_literal: true

class Ajax::AnonymousBlockController < AjaxController
  def create
    params.require :question

    question = Question.find(params[:question])

    AnonymousBlock.create!(
      user:       current_user,
      identifier: AnonymousBlock.get_identifier(question.author_identifier),
      question:   question
    )

    question.inboxes.first.destroy

    @response[:status] = :okay
    @response[:message] = I18n.t("messages.block.create.okay")
    @response[:success] = true
  end

  def destroy
    params.require :id

    block = AnonymousBlock.find(params[:id])
    if current_user != block.user
      @response[:status] = :nopriv
      @response[:message] = I18n.t("messages.block.destroy.nopriv")<commit_msg>Fix double-hashing in `Ajax::AnonymousBlockController#create`<commit_after># frozen_string_literal: true

class Ajax::AnonymousBlockController < AjaxController
  def create
    params.require :question

    question = Question.find(params[:question])

    AnonymousBlock.create!(
      user:       current_user,
      identifier: question.author_identifier,
      question:   question
    )

    question.inboxes.first.destroy

    @response[:status] = :okay
    @response[:message] = I18n.t("messages.block.create.okay")
    @response[:success] = true
  end

  def destroy
    params.require :id

    block = AnonymousBlock.find(params[:id])
    if current_user != block.user
      @response[:status] = :nopriv
      @response[:message] = I18n.t("messages.block.destroy.nopriv")
{'fraction_non_alphanumeric': 0.11615833874107723, 'fraction_numerical': 0.005191434133679429, 'mean_word_length': 3.672727272727273, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2361915', 'n_tokens_mistral': 473, 'n_tokens_neox': 440, 'n_words': 82}