2015-09-30 12:28:13 -04:00
|
|
|
require_dependency 'discourse'
|
|
|
|
|
|
|
|
class PostActionUsersController < ApplicationController
|
|
|
|
def index
|
|
|
|
params.require(:post_action_type_id)
|
|
|
|
params.require(:id)
|
|
|
|
post_action_type_id = params[:post_action_type_id].to_i
|
|
|
|
|
|
|
|
finder = Post.where(id: params[:id].to_i)
|
|
|
|
finder = finder.with_deleted if guardian.is_staff?
|
|
|
|
|
|
|
|
post = finder.first
|
|
|
|
guardian.ensure_can_see!(post)
|
2017-06-02 14:23:56 -04:00
|
|
|
|
2015-09-30 12:28:13 -04:00
|
|
|
post_actions = post.post_actions.where(post_action_type_id: post_action_type_id)
|
2017-07-27 21:20:09 -04:00
|
|
|
.includes(:user)
|
|
|
|
.order('post_actions.created_at asc')
|
2015-09-30 12:28:13 -04:00
|
|
|
|
2017-06-02 14:23:56 -04:00
|
|
|
if !guardian.can_see_post_actors?(post.topic, post_action_type_id)
|
|
|
|
if !current_user
|
|
|
|
raise Discourse::InvalidAccess
|
|
|
|
end
|
|
|
|
post_actions = post_actions.where(user_id: current_user.id)
|
|
|
|
end
|
|
|
|
|
2015-09-30 12:28:13 -04:00
|
|
|
render_serialized(post_actions.to_a, PostActionUserSerializer, root: 'post_action_users')
|
|
|
|
end
|
|
|
|
end
|