Remove oembed for now, will submit it in another MR. Fix warnings
[akkoma] / lib / pleroma / web / router.ex
index 75d965c6d4f5d9f2e5a87d5cdeaa7121ec536c0d..914cd6a6d2f53e9c6bea0b471881716a2e93764b 100644 (file)
@@ -1,8 +1,6 @@
 defmodule Pleroma.Web.Router do
   use Pleroma.Web, :router
 
-  alias Pleroma.{Repo, User, Web.Router}
-
   pipeline :api do
     plug(:accepts, ["json"])
     plug(:fetch_session)
@@ -98,6 +96,8 @@ defmodule Pleroma.Web.Router do
     pipe_through(:admin_api)
     delete("/user", AdminAPIController, :user_delete)
     post("/user", AdminAPIController, :user_create)
+    put("/users/tag", AdminAPIController, :tag_users)
+    delete("/users/tag", AdminAPIController, :untag_users)
 
     get("/permission_group/:nickname", AdminAPIController, :right_get)
     get("/permission_group/:nickname/:permission_group", AdminAPIController, :right_get)
@@ -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