WIP. Implement oembed route and handle both json/xml for "Note" type activity
[akkoma] / lib / pleroma / web / ostatus / ostatus_controller.ex
index 9dfcf0f95a9f94a5d1bf9ff1d8503acd821b6fbf..27ec24f576b939cac7ae777a469c0e4c3cacba7f 100644 (file)
@@ -134,9 +134,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
          %User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
       case format = get_format(conn) do
         "html" ->
-          conn
-          |> put_resp_content_type("text/html")
-          |> send_file(200, Application.app_dir(:pleroma, "priv/static/index.html"))
+          serve_static_with_meta(conn, activity)
 
         _ ->
           represent_activity(conn, format, activity, user)
@@ -153,6 +151,15 @@ defmodule Pleroma.Web.OStatus.OStatusController do
     end
   end
 
+  defp serve_static_with_meta(conn, activity) do
+    {:ok, index_content } = File.read(Application.app_dir(:pleroma, "priv/static/index.html"))
+    links = OStatus.metadata(request_url(conn))
+    response = String.replace(index_content, "<!--server-generated-meta-->", links)
+    conn
+    |> put_resp_content_type("text/html")
+    |> send_resp(200, response)
+  end
+
   defp represent_activity(
          conn,
          "activity+json",