# frozen_string_literal: true class Posts::Comments::HidesController < ApplicationController before_action :load_post before_action :load_comment before_action :check_auth def create ReportableHider.new(@comment, user: current_user, reason: params[:deletion_reason]).save # HidableLogger.log(@comment, 'Deleted', current_user.name, params[:deletion_reason]) flash[:notice] = t('comments.destroy.soft_removed') redirect_to post_path(@post, anchor: "comment_#{@comment.id}") end def destroy Unhider.new(@comment).save # HidableLogger.log(@comment, 'Restored', current_user.name) respond_to do |format| format.html { redirect_to post_path(@post, anchor: "comment_#{@comment.id}") } format.json { render json: :ok } end end private def load_post @post = Post.find(params[:post_id]) end def load_comment @comment = @post.comments.find(params[:comment_id]) end def check_auth authorize! :hide, @comment end end