diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 5 | ||||
-rw-r--r-- | lib/pleroma/web/federator/federator.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/media_proxy/controller.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/ostatus/ostatus.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/salmon/salmon.ex | 2 |
6 files changed, 13 insertions, 10 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 6a78a6bee..7b1207ce2 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -351,7 +351,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do Logger.info("Federating #{id} to #{inbox}") host = URI.parse(inbox).host signature = Pleroma.Web.HTTPSignatures.sign(actor, %{host: host, "content-length": byte_size(json)}) - @httpoison.post(inbox, json, [{"Content-Type", "application/activity+json"}, {"signature", signature}]) + @httpoison.post(inbox, json, [{"Content-Type", "application/activity+json"}, {"signature", signature}], hackney: [pool: :default]) end # TODO: @@ -361,7 +361,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do {:ok, object} else Logger.info("Fetching #{id} via AP") - with {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(id, [Accept: "application/activity+json"], follow_redirect: true, timeout: 10000, recv_timeout: 20000), + with true <- String.starts_with?(id, "http"), + {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(id, [Accept: "application/activity+json"], follow_redirect: true, timeout: 10000, recv_timeout: 20000), {:ok, data} <- Poison.decode(body), nil <- Object.get_by_ap_id(data["id"]), params <- %{"type" => "Create", "to" => data["to"], "cc" => data["cc"], "actor" => data["attributedTo"], "object" => data}, diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index 4082773f3..51d293196 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -96,7 +96,7 @@ defmodule Pleroma.Web.Federator do with {:ok, %{status_code: code}} <- @httpoison.post(callback, xml, [ {"Content-Type", "application/atom+xml"}, {"X-Hub-Signature", "sha1=#{signature}"} - ], timeout: 10000, recv_timeout: 20000) do + ], timeout: 10000, recv_timeout: 20000, hackney: [pool: :default]) do Logger.debug(fn -> "Pushed to #{callback}, code #{code}" end) else e -> Logger.debug(fn -> "Couldn't push to #{callback}, #{inspect(e)}" end) diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 4f395d0f7..55675ae1c 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do reblogged = Activity.get_create_activity_by_object_ap_id(object) reblogged = render("status.json", Map.put(opts, :activity, reblogged)) - mentions = activity.data["to"] + mentions = activity.recipients |> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end) |> Enum.filter(&(&1)) |> Enum.map(fn (user) -> AccountView.render("mention.json", %{user: user}) end) @@ -60,7 +60,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do tags = object["tag"] || [] sensitive = object["sensitive"] || Enum.member?(tags, "nsfw") - mentions = activity.data["to"] + mentions = activity.recipients |> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end) |> Enum.filter(&(&1)) |> Enum.map(fn (user) -> AccountView.render("mention.json", %{user: user}) end) diff --git a/lib/pleroma/web/media_proxy/controller.ex b/lib/pleroma/web/media_proxy/controller.ex index 9327e7253..b0bbe8b64 100644 --- a/lib/pleroma/web/media_proxy/controller.ex +++ b/lib/pleroma/web/media_proxy/controller.ex @@ -3,7 +3,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do require Logger @httpoison Application.get_env(:pleroma, :httpoison) - + @max_body_length 25 * 1048576 @cache_control %{ @@ -31,7 +31,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do defp proxy_request(link) do headers = [{"user-agent", "Pleroma/MediaProxy; #{Pleroma.Web.base_url()} <#{Application.get_env(:pleroma, :instance)[:email]}>"}] - options = @httpoison.process_request_options([:insecure, {:follow_redirect, true}]) + options = @httpoison.process_request_options([:insecure, {:follow_redirect, true}]) ++ [{:pool, :default}] with \ {:ok, 200, headers, client} <- :hackney.request(:get, link, headers, "", options), headers = Enum.into(headers, Map.new), diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex index 72f5b8d52..f3ef4d690 100644 --- a/lib/pleroma/web/ostatus/ostatus.ex +++ b/lib/pleroma/web/ostatus/ostatus.ex @@ -297,7 +297,8 @@ defmodule Pleroma.Web.OStatus do end def fetch_activity_from_atom_url(url) do - with {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(url, [Accept: "application/atom+xml"], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do + with true <- String.starts_with?(url, "http"), + {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(url, [Accept: "application/atom+xml"], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do Logger.debug("Got document from #{url}, handling...") handle_incoming(body) else @@ -309,7 +310,8 @@ defmodule Pleroma.Web.OStatus do def fetch_activity_from_html_url(url) do Logger.debug("Trying to fetch #{url}") - with {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000), + with true <- String.starts_with?(url, "http"), + {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000), {:ok, atom_url} <- get_atom_url(body) do fetch_activity_from_atom_url(atom_url) else diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex index caab5d484..ab0f97d55 100644 --- a/lib/pleroma/web/salmon/salmon.ex +++ b/lib/pleroma/web/salmon/salmon.ex @@ -147,7 +147,7 @@ defmodule Pleroma.Web.Salmon do end defp send_to_user(%{info: %{"salmon" => salmon}}, feed, poster) do - with {:ok, %{status_code: code}} <- poster.(salmon, feed, [{"Content-Type", "application/magic-envelope+xml"}], timeout: 10000, recv_timeout: 20000) do + with {:ok, %{status_code: code}} <- poster.(salmon, feed, [{"Content-Type", "application/magic-envelope+xml"}], timeout: 10000, recv_timeout: 20000, hackney: [pool: :default]) do Logger.debug(fn -> "Pushed to #{salmon}, code #{code}" end) else e -> Logger.debug(fn -> "Pushing Salmon to #{salmon} failed, #{inspect(e)}" end) |