Refactor ostatus_controller, extract metatags redirection to Redirector itself. Set...
[akkoma] / lib / pleroma / web / router.ex
index 3239249f913bbb3cd5a9bf79ccfe8a68fc77717e..ad26093acaf24ec5f8f2a0f5fca0e3bb8933c1f1 100644 (file)
@@ -351,7 +351,7 @@ defmodule Pleroma.Web.Router do
   end
 
   pipeline :ostatus do
-    plug(:accepts, ["xml", "atom", "html", "activity+json"])
+    plug(:accepts, ["html", "xml", "atom", "activity+json"])
   end
 
   pipeline :oembed do
@@ -444,6 +444,7 @@ end
 
 defmodule Fallback.RedirectController do
   use Pleroma.Web, :controller
+  alias Pleroma.Web.Metadata
 
   def redirector(conn, _params) do
     conn
@@ -451,6 +452,16 @@ defmodule Fallback.RedirectController do
     |> send_file(200, Application.app_dir(:pleroma, "priv/static/index.html"))
   end
 
+  def redirector_with_meta(conn, params) do
+    {:ok, index_content } = File.read(Application.app_dir(:pleroma, "priv/static/index.html"))
+    tags = Metadata.build_tags(request_url(conn), params)
+    response = String.replace(index_content, "<!--server-generated-meta-->", tags)
+
+    conn
+    |> put_resp_content_type("text/html")
+    |> send_resp(200, response)
+  end
+
   def registration_page(conn, params) do
     redirector(conn, params)
   end