assert Enum.map(third_group["reports"], & &1["id"]) --
Enum.map(third_status_reports, & &1.id) == []
end
+
+ test "reopened report renders status data", %{
+ conn: conn,
+ first_report: first_report,
+ first_status: first_status
+ } do
+ {:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
+
+ response =
+ conn
+ |> get("/api/pleroma/admin/grouped_reports")
+ |> json_response(:ok)
+
+ first_group = Enum.find(response["reports"], &(&1["status"]["id"] == first_status.id))
+
+ assert first_group["status"] ==
+ Map.put(
+ stringify_keys(StatusView.render("show.json", %{activity: first_status})),
+ "deleted",
+ false
+ )
+ end
+
+ test "reopened report does not render status data if status has been deleted", %{
+ conn: conn,
+ first_report: first_report,
+ first_status: first_status,
+ target_user: target_user
+ } do
+ {:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
+ {:ok, _} = CommonAPI.delete(first_status.id, target_user)
+
+ refute Activity.get_by_ap_id(first_status.id)
+
+ response =
+ conn
+ |> get("/api/pleroma/admin/grouped_reports")
+ |> json_response(:ok)
+
+ assert Enum.find(response["reports"], &(&1["status"]["deleted"] == true))["status"][
+ "deleted"
+ ] == true
+
+ assert length(Enum.filter(response["reports"], &(&1["status"]["deleted"] == false))) == 2
+ end
+
+ test "account not empty if status was deleted", %{
+ conn: conn,
+ first_report: first_report,
+ first_status: first_status,
+ target_user: target_user
+ } do
+ {:ok, _} = CommonAPI.update_report_state(first_report.id, "resolved")
+ {:ok, _} = CommonAPI.delete(first_status.id, target_user)
+
+ refute Activity.get_by_ap_id(first_status.id)
+
+ response =
+ conn
+ |> get("/api/pleroma/admin/grouped_reports")
+ |> json_response(:ok)
+
+ assert Enum.find(response["reports"], &(&1["status"]["deleted"] == true))["account"]
+ end
end
- describe "POST /api/pleroma/admin/reports/:id/respond" do
- setup %{conn: conn} do
- admin = insert(:user, is_admin: true)
-
- %{conn: assign(conn, :user, admin), admin: admin}
- end
-
- test "returns created dm", %{conn: conn, admin: admin} do
- [reporter, target_user] = insert_pair(:user)
- activity = insert(:note_activity, user: target_user)
-
- {:ok, %{id: report_id}} =
- CommonAPI.report(reporter, %{
- "account_id" => target_user.id,
- "comment" => "I feel offended",
- "status_ids" => [activity.id]
- })
-
- response =
- conn
- |> post("/api/pleroma/admin/reports/#{report_id}/respond", %{
- "status" => "I will check it out"
- })
- |> json_response(:ok)
-
- recipients = Enum.map(response["mentions"], & &1["username"])
-
- assert reporter.nickname in recipients
- assert response["content"] == "I will check it out"
- assert response["visibility"] == "direct"
-
- log_entry = Repo.one(ModerationLog)
-
- assert ModerationLog.get_log_entry_message(log_entry) ==
- "@#{admin.nickname} responded with 'I will check it out' to report ##{
- response["id"]
- }"
- end
-
- test "returns 400 when status is missing", %{conn: conn} do
- conn = post(conn, "/api/pleroma/admin/reports/test/respond")
-
- assert json_response(conn, :bad_request) == "Invalid parameters"
- end
-
- test "returns 404 when report id is invalid", %{conn: conn} do
- conn =
- post(conn, "/api/pleroma/admin/reports/test/respond", %{
- "status" => "foo"
- })
-
- assert json_response(conn, :not_found) == "Not found"
- end
- end
-
describe "PUT /api/pleroma/admin/statuses/:id" do
setup %{conn: conn} do
admin = insert(:user, is_admin: true)