Top level replies (#16087)

* DEV: Show only top level replies

Adds a new query param to the topic view so that we can filter out posts
that aren't top level replies. If a post is a reply to another post
instead of the original topic post we should not include it in the
response if the `filter_top_level_replies` query param is present.

* add rspec test
This commit is contained in:
Blake Erickson
2022-03-02 13:25:36 -07:00
committed by GitHub
parent ea3a58d051
commit df2441ee37
3 changed files with 33 additions and 2 deletions

View File

@ -63,7 +63,7 @@ class TopicsController < ApplicationController
# arrays are not supported
params[:page] = params[:page].to_i rescue 1
opts = params.slice(:username_filters, :filter, :page, :post_number, :show_deleted, :replies_to_post_number, :filter_upwards_post_id)
opts = params.slice(:username_filters, :filter, :page, :post_number, :show_deleted, :replies_to_post_number, :filter_upwards_post_id, :filter_top_level_replies)
username_filters = opts[:username_filters]
opts[:print] = true if params[:print].present?
@ -1221,7 +1221,7 @@ class TopicsController < ApplicationController
scope: guardian,
root: false,
include_raw: !!params[:include_raw],
exclude_suggested_and_related: !!params[:replies_to_post_number] || !!params[:filter_upwards_post_id]
exclude_suggested_and_related: !!params[:replies_to_post_number] || !!params[:filter_upwards_post_id] || !!params[:filter_top_level_replies]
)
respond_to do |format|