add ignore hosts and TLDs for rich_media
This commit is contained in:
parent
0cb8e710fb
commit
4ad15ad2a9
7 changed files with 67 additions and 21 deletions
|
|
@ -312,7 +312,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/statuses", %{
|
||||
"status" => "http://example.com/ogp"
|
||||
"status" => "https://example.com/ogp"
|
||||
})
|
||||
|
||||
assert %{"id" => id, "card" => %{"title" => "The Rock"}} = json_response(conn, 200)
|
||||
|
|
@ -2557,7 +2557,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
end
|
||||
|
||||
test "returns rich-media card", %{conn: conn, user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "http://example.com/ogp"})
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "https://example.com/ogp"})
|
||||
|
||||
card_data = %{
|
||||
"image" => "http://ia.media-imdb.com/images/rock.jpg",
|
||||
|
|
@ -2589,7 +2589,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
# works with private posts
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "http://example.com/ogp", "visibility" => "direct"})
|
||||
CommonAPI.post(user, %{"status" => "https://example.com/ogp", "visibility" => "direct"})
|
||||
|
||||
response_two =
|
||||
conn
|
||||
|
|
@ -2601,7 +2601,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
end
|
||||
|
||||
test "replaces missing description with an empty string", %{conn: conn, user: user} do
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "http://example.com/ogp-missing-data"})
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "https://example.com/ogp-missing-data"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -50,13 +50,13 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
"status" => "[test](http://example.com/ogp)",
|
||||
"status" => "[test](https://example.com/ogp)",
|
||||
"content_type" => "text/markdown"
|
||||
})
|
||||
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
|
||||
assert %{page_url: "http://example.com/ogp", rich_media: _} =
|
||||
assert %{page_url: "https://example.com/ogp", rich_media: _} =
|
||||
Pleroma.Web.RichMedia.Helpers.fetch_data_for_activity(activity)
|
||||
end
|
||||
|
||||
|
|
@ -97,19 +97,21 @@ defmodule Pleroma.Web.RichMedia.HelpersTest do
|
|||
|
||||
test "refuses to crawl URLs of private network from posts" do
|
||||
user = insert(:user)
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{"status" => "http://127.0.0.1:4000/notice/9kCP7VNyPJXFOXDrgO"})
|
||||
|
||||
{:ok, activity2} = CommonAPI.post(user, %{"status" => "https://10.111.10.1/notice/9kCP7V"})
|
||||
|
||||
{:ok, activity3} = CommonAPI.post(user, %{"status" => "https://172.16.32.40/notice/9kCP7V"})
|
||||
{:ok, activity4} = CommonAPI.post(user, %{"status" => "https://192.168.10.40/notice/9kCP7V"})
|
||||
{:ok, activity5} = CommonAPI.post(user, %{"status" => "https://pleroma.local/notice/9kCP7V"})
|
||||
|
||||
Config.put([:rich_media, :enabled], true)
|
||||
|
||||
assert %{} = Helpers.fetch_data_for_activity(activity)
|
||||
assert %{} = Helpers.fetch_data_for_activity(activity2)
|
||||
assert %{} = Helpers.fetch_data_for_activity(activity3)
|
||||
assert %{} = Helpers.fetch_data_for_activity(activity4)
|
||||
assert %{} = Helpers.fetch_data_for_activity(activity5)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue