API: kill /api/rich_media/parse endpoint
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 27 Jan 2019 12:34:49 +0000 (12:34 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 28 Jan 2019 05:53:17 +0000 (05:53 +0000)
lib/pleroma/web/rich_media/controllers/rich_media_controller.ex [deleted file]
lib/pleroma/web/router.ex
test/web/rich_media/controllers/rich_media_controller_test.exs [deleted file]

diff --git a/lib/pleroma/web/rich_media/controllers/rich_media_controller.ex b/lib/pleroma/web/rich_media/controllers/rich_media_controller.ex
deleted file mode 100644 (file)
index 9101996..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-defmodule Pleroma.Web.RichMedia.RichMediaController do
-  use Pleroma.Web, :controller
-
-  import Pleroma.Web.ControllerHelper, only: [json_response: 3]
-
-  def parse(conn, %{"url" => url}) do
-    case Pleroma.Web.RichMedia.Parser.parse(url) do
-      {:ok, data} ->
-        conn
-        |> json_response(200, data)
-
-      {:error, msg} ->
-        conn
-        |> json_response(404, msg)
-    end
-  end
-end
index 31f739738d32793e0e3f773269ee3e4c527d5801..68e7a44b623ea704b965ebeb394750a6cab2ce59 100644 (file)
@@ -239,12 +239,6 @@ defmodule Pleroma.Web.Router do
     put("/settings", MastodonAPIController, :put_settings)
   end
 
-  scope "/api", Pleroma.Web.RichMedia do
-    pipe_through(:authenticated_api)
-
-    get("/rich_media/parse", RichMediaController, :parse)
-  end
-
   scope "/api/v1", Pleroma.Web.MastodonAPI do
     pipe_through(:api)
     get("/instance", MastodonAPIController, :masto_instance)
diff --git a/test/web/rich_media/controllers/rich_media_controller_test.exs b/test/web/rich_media/controllers/rich_media_controller_test.exs
deleted file mode 100644 (file)
index fef1265..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Web.RichMedia.RichMediaControllerTest do
-  use Pleroma.Web.ConnCase
-  import Pleroma.Factory
-  import Tesla.Mock
-
-  setup do
-    mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
-    :ok
-  end
-
-  describe "GET /api/rich_media/parse" do
-    setup do
-      user = insert(:user)
-
-      [user: user]
-    end
-
-    test "returns 404 if not metadata found", %{user: user} do
-      build_conn()
-      |> with_credentials(user.nickname, "test")
-      |> get("/api/rich_media/parse", %{"url" => "http://example.com/empty"})
-      |> json_response(404)
-    end
-
-    test "returns OGP metadata", %{user: user} do
-      response =
-        build_conn()
-        |> with_credentials(user.nickname, "test")
-        |> get("/api/rich_media/parse", %{"url" => "http://example.com/ogp"})
-        |> json_response(200)
-
-      assert response == %{
-               "image" => "http://ia.media-imdb.com/images/rock.jpg",
-               "title" => "The Rock",
-               "type" => "video.movie",
-               "url" => "http://www.imdb.com/title/tt0117500/"
-             }
-    end
-  end
-
-  defp with_credentials(conn, username, password) do
-    header_content = "Basic " <> Base.encode64("#{username}:#{password}")
-    put_req_header(conn, "authorization", header_content)
-  end
-end