Commit 47887ac8 authored by lain's avatar lain
Browse files

MastoAPI: Fix always-sensitive bugs.

parent 846d59a5
Pipeline #444 failed with stage
in 2 minutes and 57 seconds
......@@ -10,7 +10,7 @@ def linkify(text) do
def parse_tags(text, data \\ %{}) do
Regex.scan(@tag_regex, text)
|> Enum.map(fn (["#" <> tag = full_tag]) -> {full_tag, String.downcase(tag)} end)
|> (fn map -> if data["sensitive"], do: [{"#nsfw", "nsfw"}] ++ map, else: map end).()
|> (fn map -> if data["sensitive"] in [true, "True", "true"], do: [{"#nsfw", "nsfw"}] ++ map, else: map end).()
end
def parse_mentions(text) do
......
......@@ -162,7 +162,7 @@ def home_timeline(%{assigns: %{user: user}} = conn, params) do
def public_timeline(%{assigns: %{user: user}} = conn, params) do
params = params
|> Map.put("type", ["Create", "Announce"])
|> Map.put("local_only", !!params["local"])
|> Map.put("local_only", params["local"] in [true, "True", "true"])
|> Map.put("blocking_user", user)
activities = ActivityPub.fetch_public_activities(params)
......
......@@ -35,7 +35,7 @@ test "the public timeline", %{conn: conn} do
{:ok, [_activity]} = OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
conn = conn
|> get("/api/v1/timelines/public")
|> get("/api/v1/timelines/public", %{"local" => "False"})
assert length(json_response(conn, 200)) == 2
......@@ -50,9 +50,9 @@ test "posting a status", %{conn: conn} do
conn = conn
|> assign(:user, user)
|> post("/api/v1/statuses", %{"status" => "cofe", "spoiler_text" => "2hu"})
|> post("/api/v1/statuses", %{"status" => "cofe", "spoiler_text" => "2hu", "sensitive" => "false"})
assert %{"content" => "cofe", "id" => id, "spoiler_text" => "2hu"} = json_response(conn, 200)
assert %{"content" => "cofe", "id" => id, "spoiler_text" => "2hu", "sensitive" => false} = json_response(conn, 200)
assert Repo.get(Activity, id)
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment