diff options
author | tusooa <tusooa@kazv.moe> | 2023-03-01 20:09:50 -0500 |
---|---|---|
committer | tusooa <tusooa@kazv.moe> | 2023-03-01 20:09:50 -0500 |
commit | f33401f54be8c216d04e4bd9747801309dd2b4a6 (patch) | |
tree | 801241b58afee15329bcd7dbfb5ed1d888e6c4c6 /lib | |
parent | 8a0162cd9694a1c5bf131fefb6e6a8d3dcb68fae (diff) | |
parent | fd46f83d2daca51055633875671e5fa41e454ca4 (diff) | |
download | pleroma-f33401f54be8c216d04e4bd9747801309dd2b4a6.tar.gz pleroma-f33401f54be8c216d04e4bd9747801309dd2b4a6.zip |
Merge remote-tracking branch 'upstream/stable' into mergeback/2.5.1
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index b9206b4da..1ab2db94a 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -1453,13 +1453,22 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub 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 + 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 |