summaryrefslogtreecommitdiff
path: root/app/controllers/posts/hashes_controller.rb
blob: d22e180475811ae7edacfe8854ab58700dadd738 (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
# frozen_string_literal: true

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

  def destroy
    @post.media.update(orig_sha512_hash: nil)

    # HidableLogger.log(@post, 'Hashes cleared', current_user.name)

    flash[:notice] = t('posts.clear_hash.success')

    redirect_to short_post_path(@post)
  end

  private

  def load_post
    @post = Post.find_by!(id: params[:post_id])
  end

  def check_auth
    authorize! :hide, @post
  end
end