<commit_before>class PostsController < ApplicationController
  before_action :set_post, except: [:new, :create, :index]
  before_action :require_login, except: [:show, :index, :callback]
  before_action :require_post_ownership, only: [:edit, :update, :destroy]
  skip_before_filter :verify_authenticity_token, only: [:callback]

  def show
    @images = @post.images
    @profile = ProfilePresenter.new(@post.user)
  end

  def index
    @posts = Search.for(params[:search]).page(params[:page])
  end

  def new
    @post = Post.new
  end

  def upvote
    @post.liked_by current_user
    redirect_to :back, notice: "upvote :)"
  end

  def downvote
    @post.downvote_from current_user
    redirect_to :back, notice: "downvote :("
  end

  def callback
    @paypay = @post.build_paypal_callback(callback_params)
    @paypay.response = callback_params
    @paypay.save
    @paypay.trigger_status_change
    render nothing: true
  end

  def callback_params
    params.permit(
      :payment_date, :payment_type, :payment_status, :payer_status, :payer_id, :payer_email, :payment_fee, :payment_gross,
      :handling_amount, :shipping, :first_name, :last_name ,
      :address_name, :address_status, :address_street, :address_city, :address_state, :address_zip, :address_country_code, :address_country,
      :transaction_subject, :receiver_email, :receiver_id, :business, :protection_eligibility,
      :verify_sign, :ipn_track_id, :txn_id, :txn_type, :residence_country)
  end

  def create
    @post = current_user.posts.build(post_params)

    if @post.save
      @post.liked_by current_user
      @post.send_notifications
      redirect_to @post, notice: 'Post was successfully created. Add images for more upvotes!'
    else
      render action: 'new'
    end
  end

  def edit
  end

  def update
    if @post.update(post_params)
      redirect_to @post, notice: 'Post was successfully updated.'
    else
      render action: 'edit'
    end
  end

  def destroy
    @post.destroy
    redirect_to posts_url, notice: 'Post was successfully destroyed.'
  end

private
  def set_post
    @post = Post.find(params[:id])
  end

  def post_params
    params.require(:post).permit(:title, :size_id, :price, :body, :status_enum)
  end
end<commit_msg>send tweets after post update<commit_after>class PostsController < ApplicationController
  before_action :set_post, except: [:new, :create, :index]
  before_action :require_login, except: [:show, :index, :callback]
  before_action :require_post_ownership, only: [:edit, :update, :destroy]
  skip_before_filter :verify_authenticity_token, only: [:callback]

  def show
    @images = @post.images
    @profile = ProfilePresenter.new(@post.user)
  end

  def index
    @posts = Search.for(params[:search]).page(params[:page])
  end

  def new
    @post = Post.new
  end

  def upvote
    @post.liked_by current_user
    redirect_to :back, notice: "upvote :)"
  end

  def downvote
    @post.downvote_from current_user
    redirect_to :back, notice: "downvote :("
  end

  def callback
    @paypay = @post.build_paypal_callback(callback_params)
    @paypay.response = callback_params
    @paypay.save
    @paypay.trigger_status_change
    render nothing: true
  end

  def callback_params
    params.permit(
      :payment_date, :payment_type, :payment_status, :payer_status, :payer_id, :payer_email, :payment_fee, :payment_gross,
      :handling_amount, :shipping, :first_name, :last_name ,
      :address_name, :address_status, :address_street, :address_city, :address_state, :address_zip, :address_country_code, :address_country,
      :transaction_subject, :receiver_email, :receiver_id, :business, :protection_eligibility,
      :verify_sign, :ipn_track_id, :txn_id, :txn_type, :residence_country)
  end

  def create
    @post = current_user.posts.build(post_params)

    if @post.save
      @post.liked_by current_user
      @post.send_notifications
      redirect_to @post, notice: 'Post was successfully created. Add images for more upvotes!'
    else
      render action: 'new'
    end
  end

  def edit
  end

  def update
    if @post.update(post_params)
      @post.send_notifications
      redirect_to @post, notice: 'Post was successfully updated.'
    else
      render action: 'edit'
    end
  end

  def destroy
    @post.destroy
    redirect_to posts_url, notice: 'Post was successfully destroyed.'
  end

private
  def set_post
    @post = Post.find(params[:id])
  end

  def post_params
    params.require(:post).permit(:title, :size_id, :price, :body, :status_enum)
  end
end
{'fraction_non_alphanumeric': 0.10090328266137916, 'fraction_numerical': 0.0, 'mean_word_length': 3.908108108108108, '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': '505154', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1483, 'n_words': 362}