X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Femoji%2Fpack.ex;h=8d233d5e4241dcacb045c2876e1c65f2d56fa12c;hb=364b6969eb7c79e57ed02345ddff4f48519e6b0a;hp=f768af19f7891a8b5be8c9520cf832eb9a66338a;hpb=d501e55ec7fbb31d3baef548f9f773648c13896e;p=akkoma diff --git a/lib/pleroma/emoji/pack.ex b/lib/pleroma/emoji/pack.ex index f768af19f..8d233d5e4 100644 --- a/lib/pleroma/emoji/pack.ex +++ b/lib/pleroma/emoji/pack.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Emoji.Pack do @@ -20,6 +20,8 @@ defmodule Pleroma.Emoji.Pack do name: String.t() } + @cachex Pleroma.Config.get([:cachex, :provider], Cachex) + alias Pleroma.Emoji alias Pleroma.Emoji.Pack alias Pleroma.Utils @@ -415,7 +417,7 @@ defmodule Pleroma.Emoji.Pack do ttl_per_file = Pleroma.Config.get!([:emoji, :shared_pack_cache_seconds_per_file]) overall_ttl = :timer.seconds(ttl_per_file * Enum.count(files)) - Cachex.put!( + @cachex.put( :emoji_packs_cache, pack.name, # if pack.json MD5 changes, the cache is not valid anymore @@ -540,7 +542,7 @@ defmodule Pleroma.Emoji.Pack do defp http_get(%URI{} = url), do: url |> to_string() |> http_get() defp http_get(url) do - with {:ok, %{body: body}} <- Pleroma.HTTP.get(url, [], pool: :default) do + with {:ok, %{body: body}} <- Pleroma.HTTP.get(url, [], []) do Jason.decode(body) end end @@ -618,7 +620,7 @@ defmodule Pleroma.Emoji.Pack do defp fetch_archive(pack) do hash = :crypto.hash(:md5, File.read!(pack.pack_file)) - case Cachex.get!(:emoji_packs_cache, pack.name) do + case @cachex.get!(:emoji_packs_cache, pack.name) do %{hash: ^hash, pack_data: archive} -> archive _ -> create_archive_and_cache(pack, hash) end