mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 16:40:29 +00:00
MastoAPI: Fix always-sensitive bugs.
This commit is contained in:
parent
846d59a536
commit
47887ac848
3 changed files with 5 additions and 5 deletions
|
@ -10,7 +10,7 @@ defmodule Pleroma.Formatter do
|
||||||
def parse_tags(text, data \\ %{}) do
|
def parse_tags(text, data \\ %{}) do
|
||||||
Regex.scan(@tag_regex, text)
|
Regex.scan(@tag_regex, text)
|
||||||
|> Enum.map(fn (["#" <> tag = full_tag]) -> {full_tag, String.downcase(tag)} end)
|
|> 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
|
end
|
||||||
|
|
||||||
def parse_mentions(text) do
|
def parse_mentions(text) do
|
||||||
|
|
|
@ -162,7 +162,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||||
def public_timeline(%{assigns: %{user: user}} = conn, params) do
|
def public_timeline(%{assigns: %{user: user}} = conn, params) do
|
||||||
params = params
|
params = params
|
||||||
|> Map.put("type", ["Create", "Announce"])
|
|> 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)
|
|> Map.put("blocking_user", user)
|
||||||
|
|
||||||
activities = ActivityPub.fetch_public_activities(params)
|
activities = ActivityPub.fetch_public_activities(params)
|
||||||
|
|
|
@ -35,7 +35,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
{:ok, [_activity]} = OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
|
{:ok, [_activity]} = OStatus.fetch_activity_from_url("https://shitposter.club/notice/2827873")
|
||||||
|
|
||||||
conn = conn
|
conn = conn
|
||||||
|> get("/api/v1/timelines/public")
|
|> get("/api/v1/timelines/public", %{"local" => "False"})
|
||||||
|
|
||||||
assert length(json_response(conn, 200)) == 2
|
assert length(json_response(conn, 200)) == 2
|
||||||
|
|
||||||
|
@ -50,9 +50,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
||||||
|
|
||||||
conn = conn
|
conn = conn
|
||||||
|> assign(:user, user)
|
|> 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)
|
assert Repo.get(Activity, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue