projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8a3d430
)
passing adapter options directly without adapter key
author
Alexander Strizhakov
<alex.strizhakov@gmail.com>
Mon, 7 Sep 2020 13:57:42 +0000
(16:57 +0300)
committer
Alexander Strizhakov
<alex.strizhakov@gmail.com>
Mon, 7 Sep 2020 16:59:17 +0000
(19:59 +0300)
config/test.exs
patch
|
blob
|
history
lib/mix/tasks/pleroma/benchmark.ex
patch
|
blob
|
history
lib/mix/tasks/pleroma/frontend.ex
patch
|
blob
|
history
lib/pleroma/http/ex_aws.ex
patch
|
blob
|
history
lib/pleroma/http/http.ex
patch
|
blob
|
history
lib/pleroma/http/tzdata.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex
patch
|
blob
|
history
lib/pleroma/web/rel_me.ex
patch
|
blob
|
history
lib/pleroma/web/rich_media/helpers.ex
patch
|
blob
|
history
test/web/instances/instance_test.exs
patch
|
blob
|
history
test/web/mastodon_api/views/account_view_test.exs
patch
|
blob
|
history
diff --git
a/config/test.exs
b/config/test.exs
index f0358e3845569226841c0fe6132058686c32baa0..e9c2273e8560756e4c0b7ada65743ca2a9e73c9b 100644
(file)
--- a/
config/test.exs
+++ b/
config/test.exs
@@
-114,7
+114,7
@@
config :pleroma, Pleroma.Plugs.RemoteIp, enabled: false
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true
-config :pleroma, :instances_favicons, enabled:
tru
e
+config :pleroma, :instances_favicons, enabled:
fals
e
config :pleroma, Pleroma.Uploaders.S3,
bucket: nil,
config :pleroma, Pleroma.Uploaders.S3,
bucket: nil,
diff --git
a/lib/mix/tasks/pleroma/benchmark.ex
b/lib/mix/tasks/pleroma/benchmark.ex
index dd2b9c8f278b26d28506b14a413d341a704c6417..a607d5d4ff76b0b883cef63ab395f58210081a40 100644
(file)
--- a/
lib/mix/tasks/pleroma/benchmark.ex
+++ b/
lib/mix/tasks/pleroma/benchmark.ex
@@
-91,20
+91,17
@@
defmodule Mix.Tasks.Pleroma.Benchmark do
"Without conn and without pool" => fn ->
{:ok, %Tesla.Env{}} =
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
"Without conn and without pool" => fn ->
{:ok, %Tesla.Env{}} =
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
- adapter: [pool: :no_pool, receive_conn: false]
+ pool: :no_pool,
+ receive_conn: false
)
end,
"Without conn and with pool" => fn ->
{:ok, %Tesla.Env{}} =
)
end,
"Without conn and with pool" => fn ->
{:ok, %Tesla.Env{}} =
- Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
- adapter: [receive_conn: false]
- )
+ Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], receive_conn: false)
end,
"With reused conn and without pool" => fn ->
{:ok, %Tesla.Env{}} =
end,
"With reused conn and without pool" => fn ->
{:ok, %Tesla.Env{}} =
- Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
- adapter: [pool: :no_pool]
- )
+ Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], pool: :no_pool)
end,
"With reused conn and with pool" => fn ->
{:ok, %Tesla.Env{}} = Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500")
end,
"With reused conn and with pool" => fn ->
{:ok, %Tesla.Env{}} = Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500")
diff --git
a/lib/mix/tasks/pleroma/frontend.ex
b/lib/mix/tasks/pleroma/frontend.ex
index 73df67439ccd944d74f1f7a261a28684612f6214..cbce81ab9666919d0f163a36c612d0482892f98a 100644
(file)
--- a/
lib/mix/tasks/pleroma/frontend.ex
+++ b/
lib/mix/tasks/pleroma/frontend.ex
@@
-124,7
+124,7
@@
defmodule Mix.Tasks.Pleroma.Frontend do
url = String.replace(frontend_info["build_url"], "${ref}", frontend_info["ref"])
with {:ok, %{status: 200, body: zip_body}} <-
url = String.replace(frontend_info["build_url"], "${ref}", frontend_info["ref"])
with {:ok, %{status: 200, body: zip_body}} <-
- Pleroma.HTTP.get(url, [],
adapter: [pool: :media, recv_timeout: 120_000]
) do
+ Pleroma.HTTP.get(url, [],
pool: :media, recv_timeout: 120_000
) do
unzip(zip_body, dest)
else
e -> {:error, e}
unzip(zip_body, dest)
else
e -> {:error, e}
diff --git
a/lib/pleroma/http/ex_aws.ex
b/lib/pleroma/http/ex_aws.ex
index c3f335c7326cc62471d08773ba70e894f6c81465..5cac3532f7cfd899b64b1c038106a1d2ce36ab5f 100644
(file)
--- a/
lib/pleroma/http/ex_aws.ex
+++ b/
lib/pleroma/http/ex_aws.ex
@@
-11,7
+11,7
@@
defmodule Pleroma.HTTP.ExAws do
@impl true
def request(method, url, body \\ "", headers \\ [], http_opts \\ []) do
@impl true
def request(method, url, body \\ "", headers \\ [], http_opts \\ []) do
- http_opts = Keyword.put_new(http_opts, :
adapter, pool:
:upload)
+ http_opts = Keyword.put_new(http_opts, :
pool,
:upload)
case HTTP.request(method, url, body, headers, http_opts) do
{:ok, env} ->
case HTTP.request(method, url, body, headers, http_opts) do
{:ok, env} ->
diff --git
a/lib/pleroma/http/http.ex
b/lib/pleroma/http/http.ex
index 7bc73f4a0ec8c4f0d9744a88582e8e97f67b8685..052597191fcc90d48641217f6002418462893031 100644
(file)
--- a/
lib/pleroma/http/http.ex
+++ b/
lib/pleroma/http/http.ex
@@
-60,7
+60,7
@@
defmodule Pleroma.HTTP do
{:ok, Env.t()} | {:error, any()}
def request(method, url, body, headers, options) when is_binary(url) do
uri = URI.parse(url)
{:ok, Env.t()} | {:error, any()}
def request(method, url, body, headers, options) when is_binary(url) do
uri = URI.parse(url)
- adapter_opts = AdapterHelper.options(uri, options
[:adapter]
|| [])
+ adapter_opts = AdapterHelper.options(uri, options || [])
options = put_in(options[:adapter], adapter_opts)
params = options[:params] || []
options = put_in(options[:adapter], adapter_opts)
params = options[:params] || []
diff --git
a/lib/pleroma/http/tzdata.ex
b/lib/pleroma/http/tzdata.ex
index 4539ac3599aa02fe15090b3c416e5990617474ea..09cfdadf7c8ca62d25b8be22b0928e365848c688 100644
(file)
--- a/
lib/pleroma/http/tzdata.ex
+++ b/
lib/pleroma/http/tzdata.ex
@@
-11,7
+11,7
@@
defmodule Pleroma.HTTP.Tzdata do
@impl true
def get(url, headers, options) do
@impl true
def get(url, headers, options) do
- options = Keyword.put_new(options, :
adapter, pool:
:default)
+ options = Keyword.put_new(options, :
pool,
:default)
with {:ok, %Tesla.Env{} = env} <- HTTP.get(url, headers, options) do
{:ok, {env.status, env.headers, env.body}}
with {:ok, %Tesla.Env{} = env} <- HTTP.get(url, headers, options) do
{:ok, {env.status, env.headers, env.body}}
@@
-20,7
+20,7
@@
defmodule Pleroma.HTTP.Tzdata do
@impl true
def head(url, headers, options) do
@impl true
def head(url, headers, options) do
- options = Keyword.put_new(options, :
adapter, pool:
:default)
+ options = Keyword.put_new(options, :
pool,
:default)
with {:ok, %Tesla.Env{} = env} <- HTTP.head(url, headers, options) do
{:ok, {env.status, env.headers}}
with {:ok, %Tesla.Env{} = env} <- HTTP.head(url, headers, options) do
{:ok, {env.status, env.headers}}
diff --git
a/lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex
b/lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex
index a203405a03e88c1bb6f94ec530975d1f199d7ca1..98d5954690f188133095a330de9191cb68a57fed 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/media_proxy_warming_policy.ex
@@
-22,7
+22,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.MediaProxyWarmingPolicy do
url
|> MediaProxy.url()
url
|> MediaProxy.url()
- |> HTTP.get([],
adapter:
@options)
+ |> HTTP.get([], @options)
end
def perform(:preload, %{"object" => %{"attachment" => attachments}} = _message) do
end
def perform(:preload, %{"object" => %{"attachment" => attachments}} = _message) do
diff --git
a/lib/pleroma/web/rel_me.ex
b/lib/pleroma/web/rel_me.ex
index 32bce3c1b6c1d4d5a362b401f08189a327b3b57c..28f75b18d624d297559f68e88c24b1fceea57d35 100644
(file)
--- a/
lib/pleroma/web/rel_me.ex
+++ b/
lib/pleroma/web/rel_me.ex
@@
-25,7
+25,7
@@
defmodule Pleroma.Web.RelMe do
defp parse_url(url) do
with {:ok, %Tesla.Env{body: html, status: status}} when status in 200..299 <-
defp parse_url(url) do
with {:ok, %Tesla.Env{body: html, status: status}} when status in 200..299 <-
- Pleroma.HTTP.get(url, [],
adapter:
@options),
+ Pleroma.HTTP.get(url, [], @options),
{:ok, html_tree} <- Floki.parse_document(html),
data <-
Floki.attribute(html_tree, "link[rel~=me]", "href") ++
{:ok, html_tree} <- Floki.parse_document(html),
data <-
Floki.attribute(html_tree, "link[rel~=me]", "href") ++
diff --git
a/lib/pleroma/web/rich_media/helpers.ex
b/lib/pleroma/web/rich_media/helpers.ex
index 084a664661ac7254d3a035739227934d2446f410..bd7f03cbeba8c3bf55bf86341e47440ae17464d9 100644
(file)
--- a/
lib/pleroma/web/rich_media/helpers.ex
+++ b/
lib/pleroma/web/rich_media/helpers.ex
@@
-87,6
+87,6
@@
defmodule Pleroma.Web.RichMedia.Helpers do
def rich_media_get(url) do
headers = [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]
def rich_media_get(url) do
headers = [{"user-agent", Pleroma.Application.user_agent() <> "; Bot"}]
- Pleroma.HTTP.get(url, headers,
adapter:
@options)
+ Pleroma.HTTP.get(url, headers, @options)
end
end
end
end
diff --git
a/test/web/instances/instance_test.exs
b/test/web/instances/instance_test.exs
index dc6ace843f43a69d475bc991601f4649024b6112..5d4efcebebb69688e8402a587392759001a888b5 100644
(file)
--- a/
test/web/instances/instance_test.exs
+++ b/
test/web/instances/instance_test.exs
@@
-112,6
+112,8
@@
defmodule Pleroma.Instances.InstanceTest do
end
test "Returns nil on too long favicon URLs" do
end
test "Returns nil on too long favicon URLs" do
+ clear_config([:instances_favicons, :enabled], true)
+
long_favicon_url =
"https://Lorem.ipsum.dolor.sit.amet/consecteturadipiscingelit/Praesentpharetrapurusutaliquamtempus/Mauriseulaoreetarcu/atfacilisisorci/Nullamporttitor/nequesedfeugiatmollis/dolormagnaefficiturlorem/nonpretiumsapienorcieurisus/Nullamveleratsem/Maecenassedaccumsanexnam/favicon.png"
long_favicon_url =
"https://Lorem.ipsum.dolor.sit.amet/consecteturadipiscingelit/Praesentpharetrapurusutaliquamtempus/Mauriseulaoreetarcu/atfacilisisorci/Nullamporttitor/nequesedfeugiatmollis/dolormagnaefficiturlorem/nonpretiumsapienorcieurisus/Nullamveleratsem/Maecenassedaccumsanexnam/favicon.png"
diff --git
a/test/web/mastodon_api/views/account_view_test.exs
b/test/web/mastodon_api/views/account_view_test.exs
index 8f37efa3c3e2b8df5fa13bfa7955ac5f898fbb3c..68a5d0091ba34ccf7e46a880bfd71a7c2eed8d4b 100644
(file)
--- a/
test/web/mastodon_api/views/account_view_test.exs
+++ b/
test/web/mastodon_api/views/account_view_test.exs
@@
-5,7
+5,6
@@
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
use Pleroma.DataCase
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
use Pleroma.DataCase
- alias Pleroma.Config
alias Pleroma.User
alias Pleroma.UserRelationship
alias Pleroma.Web.CommonAPI
alias Pleroma.User
alias Pleroma.UserRelationship
alias Pleroma.Web.CommonAPI
@@
-19,8
+18,6
@@
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
:ok
end
:ok
end
- setup do: clear_config([:instances_favicons, :enabled])
-
test "Represent a user account" do
background_image = %{
"url" => [%{"href" => "https://example.com/images/asuka_hospital.png"}]
test "Represent a user account" do
background_image = %{
"url" => [%{"href" => "https://example.com/images/asuka_hospital.png"}]
@@
-78,8
+75,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
pleroma: %{
ap_id: user.ap_id,
background_image: "https://example.com/images/asuka_hospital.png",
pleroma: %{
ap_id: user.ap_id,
background_image: "https://example.com/images/asuka_hospital.png",
- favicon:
- "https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png",
+ favicon: nil,
confirmation_pending: false,
tags: [],
is_admin: false,
confirmation_pending: false,
tags: [],
is_admin: false,
@@
-98,22
+94,29
@@
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
assert expected == AccountView.render("show.json", %{user: user, skip_visibility_check: true})
end
assert expected == AccountView.render("show.json", %{user: user, skip_visibility_check: true})
end
- test "Favicon is nil when :instances_favicons is disabled" do
- user = insert(:user)
+ describe "favicon" do
+ setup do
+ [user: insert(:user)]
+ end
- Config.put([:instances_favicons, :enabled], true)
+ test "is parsed when :instance_favicons is enabled", %{user: user} do
+ clear_config([:instances_favicons, :enabled], true)
- assert %{
- pleroma: %{
- favicon:
- "https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png"
- }
- } = AccountView.render("show.json", %{user: user, skip_visibility_check: true})
+ assert %{
+ pleroma: %{
+ favicon:
+ "https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png"
+ }
+ } = AccountView.render("show.json", %{user: user, skip_visibility_check: true})
+ end
- Config.put([:instances_favicons, :enabled], false)
+ test "is nil when :instances_favicons is disabled", %{user: user} do
+ assert %{pleroma: %{favicon: nil}} =
+ AccountView.render("show.json", %{user: user, skip_visibility_check: true})
+ end
+ end
- assert %{pleroma: %{favicon: nil}} =
- AccountView.render("show.json", %{user: user, skip_visibility_check: true})
+ test "Favicon when :instance_favicons is enabled" do
end
test "Represent the user account for the account owner" do
end
test "Represent the user account for the account owner" do
@@
-173,8
+176,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
pleroma: %{
ap_id: user.ap_id,
background_image: nil,
pleroma: %{
ap_id: user.ap_id,
background_image: nil,
- favicon:
- "https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png",
+ favicon: nil,
confirmation_pending: false,
tags: [],
is_admin: false,
confirmation_pending: false,
tags: [],
is_admin: false,