projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add debug logs to timeline rendering to assist debugging
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
activity_pub.ex
diff --git
a/lib/pleroma/web/activity_pub/activity_pub.ex
b/lib/pleroma/web/activity_pub/activity_pub.ex
index 521c8b8520c2aac8f11f5a8fa6d80519a257f617..649bf909544d3f07f484c2bf966623bc29ec4e7b 100644
(file)
--- a/
lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/
lib/pleroma/web/activity_pub/activity_pub.ex
@@
-1502,13
+1502,22
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
@spec upload(Upload.source(), keyword()) :: {:ok, Object.t()} | {:error, any()}
def upload(file, opts \\ []) do
@spec upload(Upload.source(), keyword()) :: {:ok, Object.t()} | {:error, any()}
def upload(file, opts \\ []) do
- with {:ok, data} <- Upload.store(
file
, opts) do
+ with {:ok, data} <- Upload.store(
sanitize_upload_file(file)
, opts) do
obj_data = Maps.put_if_present(data, "actor", opts[:actor])
Repo.insert(%Object{data: obj_data})
end
end
obj_data = Maps.put_if_present(data, "actor", opts[:actor])
Repo.insert(%Object{data: obj_data})
end
end
+ defp sanitize_upload_file(%Plug.Upload{filename: filename} = upload) when is_binary(filename) do
+ %Plug.Upload{
+ upload
+ | filename: Path.basename(filename)
+ }
+ end
+
+ defp sanitize_upload_file(upload), do: upload
+
@spec get_actor_url(any()) :: binary() | nil
defp get_actor_url(url) when is_binary(url), do: url
defp get_actor_url(%{"href" => href}) when is_binary(href), do: href
@spec get_actor_url(any()) :: binary() | nil
defp get_actor_url(url) when is_binary(url), do: url
defp get_actor_url(%{"href" => href}) when is_binary(href), do: href
@@
-1531,6
+1540,10
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
defp normalize_image(urls) when is_list(urls), do: urls |> List.first() |> normalize_image()
defp normalize_image(_), do: nil
defp normalize_image(urls) when is_list(urls), do: urls |> List.first() |> normalize_image()
defp normalize_image(_), do: nil
+ defp normalize_also_known_as(aka) when is_list(aka), do: aka
+ defp normalize_also_known_as(aka) when is_binary(aka), do: [aka]
+ defp normalize_also_known_as(nil), do: []
+
defp object_to_user_data(data, additional) do
fields =
data
defp object_to_user_data(data, additional) do
fields =
data
@@
-1576,6
+1589,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
also_known_as =
data
|> Map.get("alsoKnownAs", [])
also_known_as =
data
|> Map.get("alsoKnownAs", [])
+ |> normalize_also_known_as()
|> Enum.filter(fn url ->
case URI.parse(url) do
%URI{scheme: "http"} -> true
|> Enum.filter(fn url ->
case URI.parse(url) do
%URI{scheme: "http"} -> true
@@
-1711,7
+1725,7
@@
defmodule Pleroma.Web.ActivityPub.ActivityPub do
{:ok, maybe_update_follow_information(data)}
else
# If this has been deleted, only log a debug and not an error
{:ok, maybe_update_follow_information(data)}
else
# If this has been deleted, only log a debug and not an error
- {:error, {"Object has been deleted"
= e, _, _}
} ->
+ {:error, {"Object has been deleted"
, _, _} = e
} ->
Logger.debug("Could not decode user at fetch #{ap_id}, #{inspect(e)}")
{:error, e}
Logger.debug("Could not decode user at fetch #{ap_id}, #{inspect(e)}")
{:error, e}