diff --git a/config/config.exs b/config/config.exs
index ee81eb899..0dca26152 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -420,7 +420,8 @@ config :pleroma, Pleroma.Web.Preload,
providers: [
Pleroma.Web.Preload.Providers.Instance,
Pleroma.Web.Preload.Providers.User,
- Pleroma.Web.Preload.Providers.Timelines
+ Pleroma.Web.Preload.Providers.Timelines,
+ Pleroma.Web.Preload.Providers.StatusNet
]
config :pleroma, :http_security,
diff --git a/lib/pleroma/web/preload.ex b/lib/pleroma/web/preload.ex
index f13932b89..90e454468 100644
--- a/lib/pleroma/web/preload.ex
+++ b/lib/pleroma/web/preload.ex
@@ -9,7 +9,13 @@ defmodule Pleroma.Web.Preload do
def build_tags(_conn, params) do
preload_data =
Enum.reduce(Pleroma.Config.get([__MODULE__, :providers], []), %{}, fn parser, acc ->
- Map.merge(acc, parser.generate_terms(params))
+ terms =
+ params
+ |> parser.generate_terms()
+ |> Enum.map(fn {k, v} -> {k, Base.encode64(Jason.encode!(v))} end)
+ |> Enum.into(%{})
+
+ Map.merge(acc, terms)
end)
rendered_html =
@@ -22,8 +28,6 @@ defmodule Pleroma.Web.Preload do
end
def build_script_tag(content) do
- content = Base.encode64(content)
-
HTML.Tag.content_tag(:script, HTML.raw(content),
id: "initial-results",
type: "application/json"
diff --git a/lib/pleroma/web/preload/status_net.ex b/lib/pleroma/web/preload/status_net.ex
new file mode 100644
index 000000000..7e592d60d
--- /dev/null
+++ b/lib/pleroma/web/preload/status_net.ex
@@ -0,0 +1,24 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Preload.Providers.StatusNet do
+ alias Pleroma.Web.TwitterAPI.UtilView
+ alias Pleroma.Web.Preload.Providers.Provider
+
+ @behaviour Provider
+ @config_url :"/api/statusnet/config.json"
+
+ @impl Provider
+ def generate_terms(_params) do
+ %{}
+ |> build_config_tag()
+ end
+
+ defp build_config_tag(acc) do
+ instance = Pleroma.Config.get(:instance)
+ info_data = UtilView.status_net_config(instance)
+
+ Map.put(acc, @config_url, info_data)
+ end
+end
diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
index fd2aee175..aaca182ec 100644
--- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex
+++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex
@@ -15,6 +15,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
alias Pleroma.User
alias Pleroma.Web
alias Pleroma.Web.CommonAPI
+ alias Pleroma.Web.TwitterAPI.UtilView
alias Pleroma.Web.WebFinger
plug(Pleroma.Web.FederatingPlug when action == :remote_subscribe)
@@ -90,17 +91,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
def config(%{assigns: %{format: "xml"}} = conn, _params) do
instance = Pleroma.Config.get(:instance)
-
- response = """
-
-
- #{Keyword.get(instance, :name)}
- #{Web.base_url()}
- #{Keyword.get(instance, :limit)}
- #{!Keyword.get(instance, :registrations_open)}
-
-
- """
+ response = UtilView.status_net_config(instance)
conn
|> put_resp_content_type("application/xml")
diff --git a/lib/pleroma/web/twitter_api/views/util_view.ex b/lib/pleroma/web/twitter_api/views/util_view.ex
index 52054e020..d3bdb4f62 100644
--- a/lib/pleroma/web/twitter_api/views/util_view.ex
+++ b/lib/pleroma/web/twitter_api/views/util_view.ex
@@ -5,4 +5,18 @@
defmodule Pleroma.Web.TwitterAPI.UtilView do
use Pleroma.Web, :view
import Phoenix.HTML.Form
+ alias Pleroma.Web
+
+ def status_net_config(instance) do
+ """
+
+
+ #{Keyword.get(instance, :name)}
+ #{Web.base_url()}
+ #{Keyword.get(instance, :limit)}
+ #{!Keyword.get(instance, :registrations_open)}
+
+
+ """
+ end
end
diff --git a/test/web/preload/status_net_test.exs b/test/web/preload/status_net_test.exs
new file mode 100644
index 000000000..ab6823a7e
--- /dev/null
+++ b/test/web/preload/status_net_test.exs
@@ -0,0 +1,14 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Preload.Providers.StatusNetTest do
+ use Pleroma.DataCase
+ alias Pleroma.Web.Preload.Providers.StatusNet
+
+ setup do: {:ok, StatusNet.generate_terms(nil)}
+
+ test "it renders the info", %{"/api/statusnet/config.json": info} do
+ assert info =~ "Pleroma"
+ end
+end