mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Select+below will ask server for post ids on megatopics.
This commit is contained in:
@ -175,22 +175,34 @@ class TopicsController < ApplicationController
|
||||
render_json_dump(wordpress_serializer)
|
||||
end
|
||||
|
||||
def post_ids
|
||||
params.require(:topic_id)
|
||||
params.permit(:post_number, :username_filters, :filter)
|
||||
|
||||
options = {
|
||||
filter_post_number: params[:post_number],
|
||||
filter: params[:filter],
|
||||
skip_limit: true,
|
||||
asc: true,
|
||||
skip_custom_fields: true
|
||||
}
|
||||
|
||||
fetch_topic_view(options)
|
||||
render_json_dump(post_ids: @topic_view.posts.pluck(:id))
|
||||
end
|
||||
|
||||
def posts
|
||||
params.require(:topic_id)
|
||||
params.permit(:post_ids, :post_number, :username_filters, :filter)
|
||||
|
||||
default_options = {
|
||||
options = {
|
||||
filter_post_number: params[:post_number],
|
||||
post_ids: params[:post_ids],
|
||||
asc: ActiveRecord::Type::Boolean.new.deserialize(params[:asc]),
|
||||
filter: params[:filter]
|
||||
}
|
||||
|
||||
if (username_filters = params[:username_filters]).present?
|
||||
default_options[:username_filters] = username_filters.split(',')
|
||||
end
|
||||
|
||||
@topic_view = TopicView.new(params[:topic_id], current_user, default_options)
|
||||
fetch_topic_view(options)
|
||||
|
||||
render_json_dump(TopicViewPostsSerializer.new(@topic_view,
|
||||
scope: guardian,
|
||||
@ -714,6 +726,17 @@ class TopicsController < ApplicationController
|
||||
)
|
||||
end
|
||||
|
||||
def fetch_topic_view(options)
|
||||
check_username_filters { |usernames| options[:username_filters] = usernames }
|
||||
@topic_view = TopicView.new(params[:topic_id], current_user, options)
|
||||
end
|
||||
|
||||
def check_username_filters
|
||||
if (username_filters = params[:username_filters]).present?
|
||||
yield(username_filters.split(',')) if block_given?
|
||||
end
|
||||
end
|
||||
|
||||
def toggle_mute
|
||||
@topic = Topic.find_by(id: params[:topic_id].to_i)
|
||||
guardian.ensure_can_see!(@topic)
|
||||
|
Reference in New Issue
Block a user