Remove oembed for now, will submit it in another MR. Fix warnings
[akkoma] / lib / pleroma / web / router.ex
index 9c06fac4f30bf9a5d3a53d207037f0f83e78c629..914cd6a6d2f53e9c6bea0b471881716a2e93764b 100644 (file)
@@ -351,7 +351,11 @@ 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
+    plug(:accepts, ["json", "xml"])
   end
 
   scope "/", Pleroma.Web do
@@ -369,6 +373,12 @@ defmodule Pleroma.Web.Router do
     post("/push/subscriptions/:id", Websub.WebsubController, :websub_incoming)
   end
 
+  scope "/", Pleroma.Web do
+    pipe_through(:oembed)
+
+    get("/oembed", OEmbed.OEmbedController, :url)
+  end
+
   pipeline :activitypub do
     plug(:accepts, ["activity+json"])
     plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
@@ -434,6 +444,7 @@ end
 
 defmodule Fallback.RedirectController do
   use Pleroma.Web, :controller
+  alias Pleroma.Web.Metadata
 
   def redirector(conn, _params) do
     conn
@@ -441,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(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