From 0862c8b88d2a5b48478cbb1e59b1c0314ebace53 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Fri, 24 Jul 2026 16:53:36 +0400 Subject: [PATCH] fix: advertise Chats feature flags correctly --- .../web/mastodon_api/views/instance_view.ex | 11 ++++--- .../mastodon_api/views/instance_view_test.exs | 31 +++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/mastodon_api/views/instance_view.ex b/lib/pleroma/web/mastodon_api/views/instance_view.ex index efb15d26e..437e42580 100644 --- a/lib/pleroma/web/mastodon_api/views/instance_view.ex +++ b/lib/pleroma/web/mastodon_api/views/instance_view.ex @@ -167,9 +167,6 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do def features do [ "pleroma_api", - if Config.get([Pleroma.Chat, :enabled], true) do - "chat" - end, "mastodon_api", "mastodon_api_grouped_notifications", "mastodon_api_streaming", @@ -205,8 +202,12 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do end, "pleroma_emoji_reactions", "pleroma_custom_emoji_reactions", - "pleroma_chat_messages", - "pleroma:pin_chats", + if Pleroma.Chat.enabled?() do + "pleroma_chat_messages" + end, + if Pleroma.Chat.enabled?() do + "pleroma:pin_chats" + end, if Config.get([:instance, :show_reactions]) do "exposable_reactions" end, diff --git a/test/pleroma/web/mastodon_api/views/instance_view_test.exs b/test/pleroma/web/mastodon_api/views/instance_view_test.exs index 66485be0e..5f1e21098 100644 --- a/test/pleroma/web/mastodon_api/views/instance_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/instance_view_test.exs @@ -114,8 +114,6 @@ defmodule Pleroma.Web.MastodonAPI.InstanceViewTest do "quote_posting", "pleroma_emoji_reactions", "pleroma_custom_emoji_reactions", - "pleroma_chat_messages", - "pleroma:pin_chats", "pleroma:get:main/ostatus", "pleroma:group_actors", "pleroma:bookmark_folders", @@ -128,6 +126,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceViewTest do "gopher", "chat", "shout", + "pleroma_chat_messages", + "pleroma:pin_chats", "relay", "safe_dm_mentions", "exposable_reactions", @@ -139,6 +139,7 @@ defmodule Pleroma.Web.MastodonAPI.InstanceViewTest do [:media_proxy, :enabled], [:gopher, :enabled], [:shout, :enabled], + [Pleroma.Chat, :enabled], [:instance, :allow_relay], [:instance, :safe_dm_mentions], [:instance, :show_reactions], @@ -443,6 +444,32 @@ defmodule Pleroma.Web.MastodonAPI.InstanceViewTest do end end + describe "chat features" do + test "advertises Shout without Chats" do + clear_config([:shout, :enabled], true) + clear_config([Pleroma.Chat, :enabled], false) + + features = InstanceView.features() + + assert "chat" in features + assert "shout" in features + refute "pleroma_chat_messages" in features + refute "pleroma:pin_chats" in features + end + + test "advertises Chats without Shout" do + clear_config([:shout, :enabled], false) + clear_config([Pleroma.Chat, :enabled], true) + + features = InstanceView.features() + + refute "chat" in features + refute "shout" in features + assert "pleroma_chat_messages" in features + assert "pleroma:pin_chats" in features + end + end + describe "federation/0" do setup do: clear_config([:mrf, :transparency], true)