mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 22:35:03 +08:00
UX: cap likes 2 (#5237)
This commit is contained in:
@ -6,6 +6,9 @@ class PostActionUsersController < ApplicationController
|
||||
params.require(:id)
|
||||
post_action_type_id = params[:post_action_type_id].to_i
|
||||
|
||||
page = params[:page].to_i
|
||||
page_size = (params[:limit] || 200).to_i
|
||||
|
||||
finder = Post.where(id: params[:id].to_i)
|
||||
finder = finder.with_deleted if guardian.is_staff?
|
||||
|
||||
@ -14,7 +17,9 @@ class PostActionUsersController < ApplicationController
|
||||
|
||||
post_actions = post.post_actions.where(post_action_type_id: post_action_type_id)
|
||||
.includes(:user)
|
||||
.offset(page * page_size)
|
||||
.order('post_actions.created_at asc')
|
||||
.limit(page_size)
|
||||
|
||||
if !guardian.can_see_post_actors?(post.topic, post_action_type_id)
|
||||
if !current_user
|
||||
@ -23,6 +28,15 @@ class PostActionUsersController < ApplicationController
|
||||
post_actions = post_actions.where(user_id: current_user.id)
|
||||
end
|
||||
|
||||
render_serialized(post_actions.to_a, PostActionUserSerializer, root: 'post_action_users')
|
||||
action_type = PostActionType.types.key(post_action_type_id)
|
||||
total_count = post["#{action_type}_count"]
|
||||
|
||||
data = { post_action_users: serialize_data(post_actions.to_a, PostActionUserSerializer) }
|
||||
|
||||
if total_count > page_size
|
||||
data[:total_rows_post_action_users] = total_count
|
||||
end
|
||||
|
||||
render_json_dump(data)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user