summaryrefslogtreecommitdiff
path: root/app/controllers/posts/source_histories_controller.rb
blob: 8b33e866861cd66f5e665be4a854fb2bacf7ec03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

require 'fileutils'

class Posts::SourceHistoriesController < ApplicationController
  before_action :load_post
  before_action :check_auth

  def destroy
    @post.source_changes.delete_all
    @post.source_url = ''
    @post.save

    # HidableLogger.log(@post, 'Sources wiped', current_user.name)

    respond_to do |format|
      format.html { redirect_to post_path(@post.id), notice: t('posts.delete_source_changes.success') }
      format.json { head :ok }
    end
  end

  private

  def load_post
    @post = Post.find(params[:post_id])
  end

  def check_auth
    authorize! :delete, SourceChange
  end
end