forked from mirrors/akkoma
AdminAPI.InstanceController: clean up tests, rename actions
This commit is contained in:
parent
54dbcfe02a
commit
bad79f79e6
3 changed files with 27 additions and 29 deletions
|
@ -19,18 +19,18 @@ defmodule Pleroma.Web.AdminAPI.InstanceController do
|
||||||
plug(
|
plug(
|
||||||
OAuthScopesPlug,
|
OAuthScopesPlug,
|
||||||
%{scopes: ["admin:read:statuses"]}
|
%{scopes: ["admin:read:statuses"]}
|
||||||
when action in [:list_instance_statuses]
|
when action in [:list_statuses]
|
||||||
)
|
)
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
OAuthScopesPlug,
|
OAuthScopesPlug,
|
||||||
%{scopes: ["admin:write:accounts", "admin:write:statuses"]}
|
%{scopes: ["admin:write:accounts", "admin:write:statuses"]}
|
||||||
when action in [:delete_instance]
|
when action in [:delete]
|
||||||
)
|
)
|
||||||
|
|
||||||
action_fallback(AdminAPI.FallbackController)
|
action_fallback(AdminAPI.FallbackController)
|
||||||
|
|
||||||
def list_instance_statuses(conn, %{"instance" => instance} = params) do
|
def list_statuses(conn, %{"instance" => instance} = params) do
|
||||||
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)
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ defmodule Pleroma.Web.AdminAPI.InstanceController do
|
||||||
|> render("index.json", %{total: result[:total], activities: result[:items], as: :activity})
|
|> render("index.json", %{total: result[:total], activities: result[:items], as: :activity})
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_instance(conn, %{"instance" => instance}) do
|
def delete(conn, %{"instance" => instance}) do
|
||||||
with {:ok, _job} <- Instance.delete_users_and_activities(instance) do
|
with {:ok, _job} <- Instance.delete_users_and_activities(instance) do
|
||||||
json(conn, instance)
|
json(conn, instance)
|
||||||
end
|
end
|
||||||
|
|
|
@ -209,8 +209,8 @@ defmodule Pleroma.Web.Router do
|
||||||
get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
|
get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
|
||||||
get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
|
get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
|
||||||
|
|
||||||
get("/instances/:instance/statuses", InstanceController, :list_instance_statuses)
|
get("/instances/:instance/statuses", InstanceController, :list_statuses)
|
||||||
delete("/instances/:instance", InstanceController, :delete_instance)
|
delete("/instances/:instance", InstanceController, :delete)
|
||||||
|
|
||||||
get("/instance_document/:name", InstanceDocumentController, :show)
|
get("/instance_document/:name", InstanceDocumentController, :show)
|
||||||
patch("/instance_document/:name", InstanceDocumentController, :update)
|
patch("/instance_document/:name", InstanceDocumentController, :update)
|
||||||
|
|
|
@ -30,7 +30,6 @@ defmodule Pleroma.Web.AdminAPI.InstanceControllerTest do
|
||||||
{:ok, %{admin: admin, token: token, conn: conn}}
|
{:ok, %{admin: admin, token: token, conn: conn}}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "instances" do
|
|
||||||
test "GET /instances/:instance/statuses", %{conn: conn} do
|
test "GET /instances/:instance/statuses", %{conn: conn} do
|
||||||
user = insert(:user, local: false, ap_id: "https://archae.me/users/archaeme")
|
user = insert(:user, local: false, ap_id: "https://archae.me/users/archaeme")
|
||||||
user2 = insert(:user, local: false, ap_id: "https://test.com/users/test")
|
user2 = insert(:user, local: false, ap_id: "https://test.com/users/test")
|
||||||
|
@ -62,7 +61,6 @@ defmodule Pleroma.Web.AdminAPI.InstanceControllerTest do
|
||||||
|
|
||||||
assert length(activities) == 3
|
assert length(activities) == 3
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
test "DELETE /instances/:instance", %{conn: conn} do
|
test "DELETE /instances/:instance", %{conn: conn} do
|
||||||
user = insert(:user, nickname: "lain@lain.com")
|
user = insert(:user, nickname: "lain@lain.com")
|
||||||
|
|
Loading…
Reference in a new issue