# frozen_string_literal: true class Posts::RepairsController < ApplicationController before_action :load_post before_action :check_auth def create # HidableLogger.log(@post, 'Repair attempted', current_user.name) if PostRepairer.new(@post).repair! respond_to do |format| format.html { redirect_to(post_path(@post), notice: t('posts.repair.success')) } format.json { head :ok } end else respond_to do |format| format.html { redirect_to(post_path(@post), error: t('posts.repair.failure')) } format.json { head :ok } end end end private def load_post @post = Post.find_by!(id: params[:post_id], destroyed_content: false) end def check_auth authorize! :repair, @post end end