Merge branch 'exclude-posts-visible-to-admin' into 'develop'
Exclude private and direct statuses visible to the admin when using godmode Closes #1599 See merge request pleroma/pleroma!2272
This commit is contained in:
commit
802b991814
@ -745,14 +745,14 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_statuses(%{assigns: %{user: admin}} = conn, params) do
|
def list_statuses(%{assigns: %{user: _admin}} = conn, params) do
|
||||||
godmode = params["godmode"] == "true" || params["godmode"] == true
|
godmode = params["godmode"] == "true" || params["godmode"] == true
|
||||||
local_only = params["local_only"] == "true" || params["local_only"] == true
|
local_only = params["local_only"] == "true" || params["local_only"] == true
|
||||||
with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
|
with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
|
||||||
{page, page_size} = page_params(params)
|
{page, page_size} = page_params(params)
|
||||||
|
|
||||||
activities =
|
activities =
|
||||||
ActivityPub.fetch_statuses(admin, %{
|
ActivityPub.fetch_statuses(nil, %{
|
||||||
"godmode" => godmode,
|
"godmode" => godmode,
|
||||||
"local_only" => local_only,
|
"local_only" => local_only,
|
||||||
"limit" => page_size,
|
"limit" => page_size,
|
||||||
|
@ -3066,7 +3066,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/pleroma/admin/statuses" do
|
describe "GET /api/pleroma/admin/statuses" do
|
||||||
test "returns all public, unlisted, and direct statuses", %{conn: conn, admin: admin} do
|
test "returns all public and unlisted statuses", %{conn: conn, admin: admin} do
|
||||||
blocked = insert(:user)
|
blocked = insert(:user)
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
User.block(admin, blocked)
|
User.block(admin, blocked)
|
||||||
@ -3085,7 +3085,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
|
|
||||||
refute "private" in Enum.map(response, & &1["visibility"])
|
refute "private" in Enum.map(response, & &1["visibility"])
|
||||||
assert length(response) == 4
|
assert length(response) == 3
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns only local statuses with local_only on", %{conn: conn} do
|
test "returns only local statuses with local_only on", %{conn: conn} do
|
||||||
@ -3102,12 +3102,16 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||||||
assert length(response) == 1
|
assert length(response) == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns private statuses with godmode on", %{conn: conn} do
|
test "returns private and direct statuses with godmode on", %{conn: conn, admin: admin} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, _} =
|
||||||
|
CommonAPI.post(user, %{"status" => "@#{admin.nickname}", "visibility" => "direct"})
|
||||||
|
|
||||||
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "private"})
|
||||||
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
{:ok, _} = CommonAPI.post(user, %{"status" => ".", "visibility" => "public"})
|
||||||
conn = get(conn, "/api/pleroma/admin/statuses?godmode=true")
|
conn = get(conn, "/api/pleroma/admin/statuses?godmode=true")
|
||||||
assert json_response(conn, 200) |> length() == 2
|
assert json_response(conn, 200) |> length() == 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user