feat(backend): add external_urls to GraphQL

Available for :
- saveAdminSettings
- adminSettings
- config

For #1764
This commit is contained in:
Massedil
2025-07-01 19:38:16 +02:00
parent 04cf4efee4
commit 88b48f3350
5 changed files with 49 additions and 1 deletions

View File

@@ -280,6 +280,11 @@ defmodule Mobilizon.GraphQL.Resolvers.Admin do
:ok <- eventually_update_instance_actor(res) do
Config.clear_config_cache()
# add external_urls
urls = Map.get(res, :external_urls, [])
external_urls = Enum.map(urls, &Config.transform_external_url/1)
res = Map.put(res, :external_urls, external_urls)
{:ok, res}
end
end

View File

@@ -88,6 +88,7 @@ defmodule Mobilizon.GraphQL.Resolvers.Config do
get_in(Application.get_env(:web_push_encryption, :vapid_details), [:public_key])
%{
external_urls: Config.external_urls(),
name: Config.instance_name(),
registrations_open: Config.instance_registrations_open?(),
registrations_moderation: Config.instance_registrations_moderation?(),

View File

@@ -159,6 +159,24 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
)
field(:instance_languages, list_of(:string), description: "The instance's languages")
field(:external_urls, list_of(:external_url),
description: "List of URL that will be shown to users"
)
end
object :external_url do
meta(:authorize, :all)
field(:label, non_null(:string), description: "A human-readable label for the external URL")
field(:url, non_null(:string), description: "The actual external URL")
field(:enabled, non_null(:boolean), description: "Whether the external URL is enabled")
end
input_object :external_url_input do
meta(:authorize, :administrator)
field(:label, non_null(:string))
field(:url, non_null(:string))
field(:enabled, non_null(:boolean))
end
@desc "The acceptable values for the instance's terms type"
@@ -475,6 +493,11 @@ defmodule Mobilizon.GraphQL.Schema.AdminType do
)
arg(:instance_languages, list_of(:string), description: "The instance's languages")
arg(:external_urls, list_of(:external_url_input),
description: "Array of external URLs with label, status, and id"
)
middleware(Rajska.QueryAuthorization, permit: :administrator)
resolve(&Admin.save_settings/3)
end

View File

@@ -103,6 +103,10 @@ defmodule Mobilizon.GraphQL.Schema.ConfigType do
)
field(:search, :search_settings, description: "The instance's search settings")
field(:external_urls, list_of(:external_url),
description: "List of URL that will be shown to users"
)
end
@desc """