fix: advertise Chats feature flags correctly

This commit is contained in:
Lain Soykaf 2026-07-24 16:53:36 +04:00
commit 0862c8b88d
No known key found for this signature in database
2 changed files with 35 additions and 7 deletions

View file

@ -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,

View file

@ -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)