From bddd4375bf01bf0fac42f58bfafb256aa0d5651c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 27 Oct 2022 13:51:25 -0500 Subject: [PATCH] Expose favicon URL in instance API --- lib/pleroma/web/mastodon_api/views/instance_view.ex | 5 ++++- .../mastodon_api/controllers/instance_controller_test.exs | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index 2215018fe2..44deca5782 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -56,7 +56,10 @@ def render("show.json", _) do }, stats: %{mau: Pleroma.User.active_user_count()}, vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key), - oauth_consumer_strategies: Pleroma.Config.oauth_consumer_strategies() + oauth_consumer_strategies: Pleroma.Config.oauth_consumer_strategies(), + favicon: + URI.merge(Pleroma.Web.Endpoint.url(), Keyword.get(instance, :favicon)) + |> to_string }, configuration: configuration(), soapbox: %{ diff --git a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs index 7dbe52c816..45aa8136ec 100644 --- a/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs +++ b/test/pleroma/web/mastodon_api/controllers/instance_controller_test.exs @@ -19,6 +19,7 @@ test "get instance information", %{conn: conn} do email = Pleroma.Config.get([:instance, :email]) thumbnail = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :instance_thumbnail]) background = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :background_image]) + favicon = Pleroma.Web.Endpoint.url() <> Pleroma.Config.get([:instance, :favicon]) # Note: not checking for "max_toot_chars" since it's optional assert %{ @@ -44,7 +45,10 @@ test "get instance information", %{conn: conn} do "background_image" => from_config_background, "shout_limit" => _, "description_limit" => _, - "rules" => _ + "rules" => _, + "pleroma" => %{ + "favicon" => from_config_favicon + } } = result assert result["version"] =~ "Pleroma" @@ -60,6 +64,7 @@ test "get instance information", %{conn: conn} do assert email == from_config_email assert thumbnail == from_config_thumbnail assert background == from_config_background + assert favicon == from_config_favicon end test "get instance stats", %{conn: conn} do