Refactor ShareVisibilitesController

closes #7196
This commit is contained in:
Steffen van Bergerem
2016-11-18 00:57:32 +01:00
committed by Benjamin Neff
parent 75f95faebe
commit 9bca03d5e9
3 changed files with 28 additions and 20 deletions

View File

@@ -7,17 +7,14 @@ class ShareVisibilitiesController < ApplicationController
before_action :authenticate_user!
def update
#note :id references a postvisibility
params[:shareable_id] ||= params[:post_id]
params[:shareable_type] ||= 'Post'
vis = current_user.toggle_hidden_shareable(accessible_post)
render :nothing => true, :status => 200
post = post_service.find!(params[:post_id])
current_user.toggle_hidden_shareable(post)
head :ok
end
private
def accessible_post
@post ||= params[:shareable_type].constantize.where(:id => params[:post_id]).select("id, guid, author_id, created_at").first
def post_service
@post_service ||= PostService.new(current_user)
end
end