From 29158681f9f6d3f16bcab011a3338a60f11afddc Mon Sep 17 00:00:00 2001 From: Ekaterina Vaartis Date: Sun, 7 Jan 2024 17:05:30 +0300 Subject: [PATCH] Fetch count before downloading the pack and use that as page size --- changelog.d/emoji-download-paginate.fix | 1 + lib/pleroma/emoji/pack.ex | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelog.d/emoji-download-paginate.fix diff --git a/changelog.d/emoji-download-paginate.fix b/changelog.d/emoji-download-paginate.fix new file mode 100644 index 000000000..e31a63380 --- /dev/null +++ b/changelog.d/emoji-download-paginate.fix @@ -0,0 +1 @@ +When downloading remote emojis packs, account for pagination \ No newline at end of file diff --git a/lib/pleroma/emoji/pack.ex b/lib/pleroma/emoji/pack.ex index 49bb93799..85f7e1877 100644 --- a/lib/pleroma/emoji/pack.ex +++ b/lib/pleroma/emoji/pack.ex @@ -251,8 +251,12 @@ def download(name, url, as) do uri = url |> String.trim() |> URI.parse() with :ok <- validate_shareable_packs_available(uri), + {:ok, %{"files_count" => files_count}} <- + uri |> URI.merge("/api/v1/pleroma/emoji/pack?name=#{name}&page_size=0") |> http_get(), {:ok, remote_pack} <- - uri |> URI.merge("/api/v1/pleroma/emoji/pack?name=#{name}") |> http_get(), + uri + |> URI.merge("/api/v1/pleroma/emoji/pack?name=#{name}&page_size=#{files_count}") + |> http_get(), {:ok, %{sha: sha, url: url} = pack_info} <- fetch_pack_info(remote_pack, uri, name), {:ok, archive} <- download_archive(url, sha), pack <- copy_as(remote_pack, as || name),