aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pleroma/user.ex2
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex9
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub_controller.ex4
-rw-r--r--lib/pleroma/web/federator/federator.ex12
-rw-r--r--lib/pleroma/web/http_signatures/http_signatures.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex4
-rw-r--r--lib/pleroma/web/media_proxy/controller.ex4
-rw-r--r--lib/pleroma/web/oauth/authorization.ex4
-rw-r--r--lib/pleroma/web/ostatus/ostatus.ex10
-rw-r--r--lib/pleroma/web/salmon/salmon.ex6
-rw-r--r--lib/pleroma/web/web_finger/web_finger.ex4
-rw-r--r--lib/pleroma/web/websub/websub.ex2
-rw-r--r--lib/pleroma/web/websub/websub_controller.ex2
-rw-r--r--lib/pleroma/web/xml/xml.ex2
-rw-r--r--test/support/httpoison_mock.ex4
-rw-r--r--test/web/mastodon_api/status_view_test.exs3
16 files changed, 42 insertions, 32 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index a503a5b3f..5da146014 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -417,7 +417,7 @@ defmodule Pleroma.User do
_ ->
case OStatus.make_user(ap_id) do
{:ok, user} -> user
- _ -> {:error, "Could not fetch by ap id"}
+ _ -> {:error, "Could not fetch by AP id"}
end
end
end
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 965f2cc9b..7b1207ce2 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -301,7 +301,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
{:ok, data} <- Poison.decode(body) do
user_data_from_user_object(data)
else
- e -> Logger.error("Could not user at fetch #{ap_id}, #{inspect(e)}")
+ e -> Logger.error("Could not decode user at fetch #{ap_id}, #{inspect(e)}")
end
end
@@ -321,7 +321,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
with {:ok, %{"ap_id" => ap_id}} when not is_nil(ap_id) <- WebFinger.finger(nickname) do
make_user_from_ap_id(ap_id)
else
- _e -> {:error, "No ap id in webfinger"}
+ _e -> {:error, "No AP id in WebFinger"}
end
end
@@ -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/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
index edbcb938a..85fc95427 100644
--- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@ -36,9 +36,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
def inbox(conn, params) do
headers = Enum.into(conn.req_headers, %{})
if !(String.contains?(headers["signature"] || "", params["actor"])) do
- Logger.info("Signature not from author, relayed message, ignoring.")
+ Logger.info("Signature not from author, relayed message, ignoring")
else
- Logger.info("Signature error.")
+ Logger.info("Signature error")
Logger.info("Could not validate #{params["actor"]}")
Logger.info(inspect(conn.req_headers))
end
diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex
index 57e11b4fb..51d293196 100644
--- a/lib/pleroma/web/federator/federator.ex
+++ b/lib/pleroma/web/federator/federator.ex
@@ -48,10 +48,10 @@ defmodule Pleroma.Web.Federator do
with actor when not is_nil(actor) <- User.get_cached_by_ap_id(activity.data["actor"]) do
{:ok, actor} = WebFinger.ensure_keys_present(actor)
if ActivityPub.is_public?(activity) do
- Logger.info(fn -> "Sending #{activity.data["id"]} out via websub" end)
+ Logger.info(fn -> "Sending #{activity.data["id"]} out via WebSub" end)
Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity)
- Logger.info(fn -> "Sending #{activity.data["id"]} out via salmon" end)
+ Logger.info(fn -> "Sending #{activity.data["id"]} out via Salmon" end)
Pleroma.Web.Salmon.publish(actor, activity)
end
@@ -61,7 +61,7 @@ defmodule Pleroma.Web.Federator do
end
def handle(:verify_websub, websub) do
- Logger.debug(fn -> "Running websub verification for #{websub.id} (#{websub.topic}, #{websub.callback})" end)
+ Logger.debug(fn -> "Running WebSub verification for #{websub.id} (#{websub.topic}, #{websub.callback})" end)
@websub.verify(websub)
end
@@ -71,7 +71,7 @@ defmodule Pleroma.Web.Federator do
end
def handle(:incoming_ap_doc, params) do
- Logger.info("Handling incoming ap activity")
+ Logger.info("Handling incoming AP activity")
with {:ok, _user} <- ap_enabled_actor(params["actor"]),
nil <- Activity.get_by_ap_id(params["id"]),
{:ok, activity} <- Transmogrifier.handle_incoming(params) do
@@ -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)
@@ -105,7 +105,7 @@ defmodule Pleroma.Web.Federator do
def handle(type, _) do
Logger.debug(fn -> "Unknown task: #{type}" end)
- {:error, "Don't know what do do with this"}
+ {:error, "Don't know what to do with this"}
end
def enqueue(type, payload, priority \\ 1) do
diff --git a/lib/pleroma/web/http_signatures/http_signatures.ex b/lib/pleroma/web/http_signatures/http_signatures.ex
index d0695cb16..0ea3b7554 100644
--- a/lib/pleroma/web/http_signatures/http_signatures.ex
+++ b/lib/pleroma/web/http_signatures/http_signatures.ex
@@ -36,7 +36,7 @@ defmodule Pleroma.Web.HTTPSignatures do
if validate_conn(conn, public_key) do
true
else
- Logger.debug("Could not validate, re-fetching user and trying one more time.")
+ Logger.debug("Could not validate, re-fetching user and trying one more time")
# Fetch user anew and try one more time
with actor_id <- conn.params["actor"],
{:ok, _user} <- ActivityPub.make_user_from_ap_id(actor_id),
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/oauth/authorization.ex b/lib/pleroma/web/oauth/authorization.ex
index 1ba5be602..5a68bd593 100644
--- a/lib/pleroma/web/oauth/authorization.ex
+++ b/lib/pleroma/web/oauth/authorization.ex
@@ -40,8 +40,8 @@ defmodule Pleroma.Web.OAuth.Authorization do
if NaiveDateTime.diff(NaiveDateTime.utc_now, valid_until) < 0 do
Repo.update(use_changeset(auth, %{used: true}))
else
- {:error, "token expired"}
+ {:error, "Token expired"}
end
end
- def use_token(%Authorization{used: true}), do: {:error, "already used"}
+ def use_token(%Authorization{used: true}), do: {:error, "Already used"}
end
diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex
index bed15e8c0..f3ef4d690 100644
--- a/lib/pleroma/web/ostatus/ostatus.ex
+++ b/lib/pleroma/web/ostatus/ostatus.ex
@@ -291,13 +291,14 @@ defmodule Pleroma.Web.OStatus do
[[_, match]] = Regex.scan(@gs_classic_regex, body)
{:ok, match}
true ->
- Logger.debug(fn -> "Couldn't find atom link in #{inspect(body)}" end)
- {:error, "Couldn't find the atom link"}
+ Logger.debug(fn -> "Couldn't find Atom link in #{inspect(body)}" end)
+ {:error, "Couldn't find the Atom link"}
end
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 46ca645d1..ab0f97d55 100644
--- a/lib/pleroma/web/salmon/salmon.ex
+++ b/lib/pleroma/web/salmon/salmon.ex
@@ -147,10 +147,10 @@ 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)
+ e -> Logger.debug(fn -> "Pushing Salmon to #{salmon} failed, #{inspect(e)}" end)
end
end
@@ -178,7 +178,7 @@ defmodule Pleroma.Web.Salmon do
remote_users(activity)
|> Enum.each(fn(remote_user) ->
Task.start(fn ->
- Logger.debug(fn -> "sending salmon to #{remote_user.ap_id}" end)
+ Logger.debug(fn -> "Sending Salmon to #{remote_user.ap_id}" end)
send_to_user(remote_user, feed, poster)
end)
end)
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex
index c59a7e82d..019210124 100644
--- a/lib/pleroma/web/web_finger/web_finger.ex
+++ b/lib/pleroma/web/web_finger/web_finger.ex
@@ -100,7 +100,7 @@ defmodule Pleroma.Web.WebFinger do
with {:ok, %{body: body}} <- @httpoison.get("https://#{domain}/.well-known/host-meta", []) do
get_template_from_xml(body)
else
- e -> {:error, "Can't find lrdd template: #{inspect(e)}"}
+ e -> {:error, "Can't find LRDD template: #{inspect(e)}"}
end
end
end
@@ -122,7 +122,7 @@ defmodule Pleroma.Web.WebFinger do
{:ok, data}
else
e ->
- Logger.debug(fn -> "Couldn't finger #{account}." end)
+ Logger.debug(fn -> "Couldn't finger #{account}" end)
Logger.debug(fn -> inspect(e) end)
{:error, e}
end
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index fa3ab7214..5caa8198c 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -98,7 +98,7 @@ defmodule Pleroma.Web.Websub do
{:ok, websub}
else {:error, reason} ->
- Logger.debug("Couldn't create subscription.")
+ Logger.debug("Couldn't create subscription")
Logger.debug(inspect(reason))
{:error, reason}
diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex
index 6c9164ec8..115b64902 100644
--- a/lib/pleroma/web/websub/websub_controller.ex
+++ b/lib/pleroma/web/websub/websub_controller.ex
@@ -20,7 +20,7 @@ defmodule Pleroma.Web.Websub.WebsubController do
# TODO: Extract this into the Websub module
def websub_subscription_confirmation(conn, %{"id" => id, "hub.mode" => "subscribe", "hub.challenge" => challenge, "hub.topic" => topic} = params) do
- Logger.debug("Got websub confirmation")
+ Logger.debug("Got WebSub confirmation")
Logger.debug(inspect(params))
lease_seconds = if params["hub.lease_seconds"] do
String.to_integer(params["hub.lease_seconds"])
diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex
index 026672ad1..8b28a7e7d 100644
--- a/lib/pleroma/web/xml/xml.ex
+++ b/lib/pleroma/web/xml/xml.ex
@@ -21,7 +21,7 @@ defmodule Pleroma.Web.XML do
doc
catch
:exit, _error ->
- Logger.debug("Couldn't parse xml: #{inspect(text)}")
+ Logger.debug("Couldn't parse XML: #{inspect(text)}")
:error
end
end
diff --git a/test/support/httpoison_mock.ex b/test/support/httpoison_mock.ex
index a8b1a60c0..a45eaf170 100644
--- a/test/support/httpoison_mock.ex
+++ b/test/support/httpoison_mock.ex
@@ -450,4 +450,8 @@ defmodule HTTPoisonMock do
def post(url, body, headers) do
{:error, "Not implemented the mock response for post #{inspect(url)}"}
end
+
+ def post(url, body, headers, options) do
+ {:error, "Not implemented the mock response for post #{inspect(url)}"}
+ end
end
diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs
index 0d396f3b8..9e2bc3c18 100644
--- a/test/web/mastodon_api/status_view_test.exs
+++ b/test/web/mastodon_api/status_view_test.exs
@@ -60,6 +60,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
recipient = "https://pleroma.soykaf.com/users/lain"
user = User.get_cached_by_ap_id(recipient) || insert(:user, %{ap_id: recipient})
+ # invalidate the cache
+ User.invalidate_cache(user)
+
{:ok, [activity]} = OStatus.handle_incoming(incoming)
status = StatusView.render("status.json", %{activity: activity})