From f1f79c0dca9198e2a427f988b60e4222f8afda57 Mon Sep 17 00:00:00 2001 From: Lain Iwakura Date: Tue, 19 Dec 2017 16:15:07 +0100 Subject: [PATCH] Fix timelines in subway tooter. --- lib/pleroma/formatter.ex | 2 +- lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 2 +- test/web/mastodon_api/mastodon_api_controller_test.exs | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index a482c74e4..2cf4b9ca4 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -10,7 +10,7 @@ defmodule Pleroma.Formatter 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"] in [true, "True", "true"], do: [{"#nsfw", "nsfw"}] ++ map, else: map end).() + |> (fn map -> if data["sensitive"] in [true, "True", "true", "1"], do: [{"#nsfw", "nsfw"}] ++ map, else: map end).() end def parse_mentions(text) do diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index a17068be8..ffa6f42c8 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -162,7 +162,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do def public_timeline(%{assigns: %{user: user}} = conn, params) do params = params |> Map.put("type", ["Create", "Announce"]) - |> Map.put("local_only", params["local"] in [true, "True", "true"]) + |> Map.put("local_only", params["local"] in [true, "True", "true", "1"]) |> Map.put("blocking_user", user) activities = ActivityPub.fetch_public_activities(params) diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 80e15f35e..79ad671d9 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -43,6 +43,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> get("/api/v1/timelines/public", %{"local" => "True"}) assert [%{"content" => "test"}] = json_response(conn, 200) + + conn = build_conn() + |> get("/api/v1/timelines/public", %{"local" => "1"}) + + assert [%{"content" => "test"}] = json_response(conn, 200) end test "posting a status", %{conn: conn} do -- 2.45.2