Prefill child safety removal reports
This commit is contained in:
parent
2a17a23f95
commit
8449ee696f
|
|
@ -2775,3 +2775,10 @@ promoted.
|
|||
errors or warnings. Production and the frozen hackathon test still return
|
||||
`404` for `/child-safety` because neither deployment includes this later local
|
||||
revision.
|
||||
- The child-safety reporting action now opens the public content-removal form
|
||||
with the CSAE/CSAM category already selected. The controller accepts only
|
||||
category values declared by the notice schema and ignores unknown query
|
||||
values. ExUnit covers both paths. A headed browser check followed the Russian
|
||||
reporting action without submitting the form and observed the expected
|
||||
`child_sexual_abuse_material` selection, no horizontal overflow, and zero
|
||||
console errors or warnings.
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@ defmodule WhoNeedHelpWeb.ContentRemovalController do
|
|||
|
||||
def new(conn, params) do
|
||||
attrs =
|
||||
case internal_location(params["location"]) do
|
||||
nil -> %{}
|
||||
location -> %{"content_locations" => location}
|
||||
end
|
||||
%{}
|
||||
|> put_if_present("content_locations", internal_location(params["location"]))
|
||||
|> put_if_present("category", permitted_category(params["category"]))
|
||||
|
||||
render_form(conn, :general, %Notice{}, attrs)
|
||||
end
|
||||
|
|
@ -143,6 +142,16 @@ defmodule WhoNeedHelpWeb.ContentRemovalController do
|
|||
end
|
||||
end
|
||||
|
||||
defp put_if_present(attrs, _key, nil), do: attrs
|
||||
defp put_if_present(attrs, key, value), do: Map.put(attrs, key, value)
|
||||
|
||||
defp permitted_category(category) when is_binary(category) do
|
||||
if category in Enum.map(Ecto.Enum.values(Notice, :category), &Atom.to_string/1),
|
||||
do: category
|
||||
end
|
||||
|
||||
defp permitted_category(_category), do: nil
|
||||
|
||||
defp current_email(%{assigns: %{current_scope: %{user: %{email: email}}}}), do: email
|
||||
defp current_email(_conn), do: nil
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,10 @@
|
|||
)}
|
||||
</p>
|
||||
<div class="mt-4 flex flex-col gap-3 sm:flex-row">
|
||||
<.link href={~p"/legal/content-removal"} class="btn btn-error">
|
||||
<.link
|
||||
href={~p"/legal/content-removal?category=child_sexual_abuse_material"}
|
||||
class="btn btn-error"
|
||||
>
|
||||
{gettext("Report child-safety content")}
|
||||
</.link>
|
||||
<.link href={~p"/support"} class="btn btn-outline">
|
||||
|
|
|
|||
|
|
@ -217,7 +217,10 @@ defmodule WhoNeedHelpWeb.PageControllerTest do
|
|||
assert html =~ "Child safety standards"
|
||||
assert html =~ "child sexual abuse and exploitation (CSAE)"
|
||||
assert html =~ "National Center for Missing & Exploited Children"
|
||||
assert html =~ ~s(href="/legal/content-removal")
|
||||
|
||||
assert html =~
|
||||
~s(href="/legal/content-removal?category=child_sexual_abuse_material")
|
||||
|
||||
assert html =~ ~s(href="/support")
|
||||
assert html =~ "Child safety standards · Who Need Help"
|
||||
assert html =~ "standards against child sexual abuse and exploitation"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,23 @@ defmodule WhoNeedHelpWeb.SupportControllerTest do
|
|||
get(conn, ~p"/legal/content-removal?location=/requests/specific-id"),
|
||||
200
|
||||
) =~ "/requests/specific-id"
|
||||
|
||||
child_safety =
|
||||
html_response(
|
||||
get(
|
||||
conn,
|
||||
~p"/legal/content-removal?category=child_sexual_abuse_material"
|
||||
),
|
||||
200
|
||||
)
|
||||
|
||||
assert child_safety =~
|
||||
~s(<option selected value="child_sexual_abuse_material">Sexual material involving a minor</option>)
|
||||
|
||||
invalid_category =
|
||||
html_response(get(conn, ~p"/legal/content-removal?category=not-a-real-category"), 200)
|
||||
|
||||
refute invalid_category =~ ~s(<option selected value="not-a-real-category">)
|
||||
end
|
||||
|
||||
test "creates support request without exposing its status token in the redirect", %{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user