mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Remove deprecated posts/:username/flagged (#21846)
This commit is contained in:
@@ -662,32 +662,6 @@ class PostsController < ApplicationController
|
|||||||
render body: nil
|
render body: nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def flagged_posts
|
|
||||||
Discourse.deprecate(
|
|
||||||
"PostsController#flagged_posts is deprecated. Please use /review instead.",
|
|
||||||
since: "2.8.0.beta4",
|
|
||||||
drop_from: "2.9",
|
|
||||||
)
|
|
||||||
|
|
||||||
params.permit(:offset, :limit)
|
|
||||||
guardian.ensure_can_see_flagged_posts!
|
|
||||||
|
|
||||||
user = fetch_user_from_params
|
|
||||||
offset = [params[:offset].to_i, 0].max
|
|
||||||
limit = [(params[:limit] || 60).to_i, 100].min
|
|
||||||
|
|
||||||
posts =
|
|
||||||
user_posts(guardian, user.id, offset: offset, limit: limit).where(
|
|
||||||
id:
|
|
||||||
PostAction
|
|
||||||
.where(post_action_type_id: PostActionType.notify_flag_type_ids)
|
|
||||||
.where(disagreed_at: nil)
|
|
||||||
.select(:post_id),
|
|
||||||
)
|
|
||||||
|
|
||||||
render_serialized(posts, AdminUserActionSerializer)
|
|
||||||
end
|
|
||||||
|
|
||||||
def deleted_posts
|
def deleted_posts
|
||||||
params.permit(:offset, :limit)
|
params.permit(:offset, :limit)
|
||||||
guardian.ensure_can_see_deleted_posts!
|
guardian.ensure_can_see_deleted_posts!
|
||||||
|
|||||||
@@ -790,10 +790,6 @@ Discourse::Application.routes.draw do
|
|||||||
:constraints => {
|
:constraints => {
|
||||||
external_id: %r{[^/]+},
|
external_id: %r{[^/]+},
|
||||||
}
|
}
|
||||||
get "#{root_path}/:username/flagged-posts" => "users#show",
|
|
||||||
:constraints => {
|
|
||||||
username: RouteFormat.username,
|
|
||||||
}
|
|
||||||
get "#{root_path}/:username/deleted-posts" => "users#show",
|
get "#{root_path}/:username/deleted-posts" => "users#show",
|
||||||
:constraints => {
|
:constraints => {
|
||||||
username: RouteFormat.username,
|
username: RouteFormat.username,
|
||||||
@@ -1003,10 +999,6 @@ Discourse::Application.routes.draw do
|
|||||||
:constraints => {
|
:constraints => {
|
||||||
username: RouteFormat.username,
|
username: RouteFormat.username,
|
||||||
}
|
}
|
||||||
get "posts/:username/flagged" => "posts#flagged_posts",
|
|
||||||
:constraints => {
|
|
||||||
username: RouteFormat.username,
|
|
||||||
}
|
|
||||||
get "posts/:username/pending" => "posts#pending",
|
get "posts/:username/pending" => "posts#pending",
|
||||||
:constraints => {
|
:constraints => {
|
||||||
username: RouteFormat.username,
|
username: RouteFormat.username,
|
||||||
|
|||||||
@@ -873,7 +873,7 @@ RSpec.describe PostsController do
|
|||||||
post "/posts.json",
|
post "/posts.json",
|
||||||
params: {
|
params: {
|
||||||
raw: "this is test post #{SecureRandom.alphanumeric}",
|
raw: "this is test post #{SecureRandom.alphanumeric}",
|
||||||
title: "tthis is a test title #{SecureRandom.alphanumeric}",
|
title: "this is a test title #{SecureRandom.alphanumeric}",
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
HTTP_API_USERNAME: user.username,
|
HTTP_API_USERNAME: user.username,
|
||||||
@@ -2242,44 +2242,6 @@ RSpec.describe PostsController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#flagged_posts" do
|
|
||||||
include_examples "action requires login", :get, "/posts/system/flagged.json"
|
|
||||||
|
|
||||||
describe "when logged in" do
|
|
||||||
it "raises an error if the user doesn't have permission to see the flagged posts" do
|
|
||||||
sign_in(user)
|
|
||||||
get "/posts/system/flagged.json"
|
|
||||||
expect(response).to be_forbidden
|
|
||||||
end
|
|
||||||
|
|
||||||
it "can see the flagged posts when authorized" do
|
|
||||||
sign_in(moderator)
|
|
||||||
get "/posts/system/flagged.json"
|
|
||||||
expect(response.status).to eq(200)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "only shows agreed and deferred flags" do
|
|
||||||
post_agreed = create_post(user: user)
|
|
||||||
post_deferred = create_post(user: user)
|
|
||||||
post_disagreed = create_post(user: user)
|
|
||||||
|
|
||||||
r0 = PostActionCreator.spam(moderator, post_agreed).reviewable
|
|
||||||
r1 = PostActionCreator.off_topic(moderator, post_deferred).reviewable
|
|
||||||
r2 = PostActionCreator.inappropriate(moderator, post_disagreed).reviewable
|
|
||||||
|
|
||||||
r0.perform(admin, :agree_and_keep)
|
|
||||||
r1.perform(admin, :ignore_and_do_nothing)
|
|
||||||
r2.perform(admin, :disagree)
|
|
||||||
|
|
||||||
sign_in(Fabricate(:moderator))
|
|
||||||
get "/posts/#{user.username}/flagged.json"
|
|
||||||
expect(response.status).to eq(200)
|
|
||||||
|
|
||||||
expect(response.parsed_body.length).to eq(2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#deleted_posts" do
|
describe "#deleted_posts" do
|
||||||
include_examples "action requires login", :get, "/posts/system/deleted.json"
|
include_examples "action requires login", :get, "/posts/system/deleted.json"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user