X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fapplication.ex;h=e3edd05ca1b1744c6039ba4e1f346247a0768780;hb=72aeb2e73b77611504e1cd524a9cb47faef6816f;hp=ced14f87ff510b68b9531f263b400b16cdd234c5;hpb=0a5b22bc3b1a0011b83e1a77f4f58700266c260a;p=akkoma diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index ced14f87f..e3edd05ca 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -110,7 +110,31 @@ defmodule Pleroma.Application do # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Pleroma.Supervisor] - Supervisor.start_link(children, opts) + result = Supervisor.start_link(children, opts) + + set_postgres_server_version() + + # Requires Config.TransferTask so ConfigDB values are loaded + steal_emoji_policy_setup() + + result + end + + defp set_postgres_server_version do + version = + with %{rows: [[version]]} <- Ecto.Adapters.SQL.query!(Pleroma.Repo, "show server_version"), + {num, _} <- Float.parse(version) do + num + else + e -> + Logger.warn( + "Could not get the postgres version: #{inspect(e)}.\nSetting the default value of 9.6" + ) + + 9.6 + end + + :persistent_term.put({Pleroma.Repo, :postgres_version}, version) end def load_custom_modules do @@ -279,4 +303,20 @@ defmodule Pleroma.Application do [Pleroma.Web.RichMedia.Helpers, Pleroma.Web.MediaProxy] |> Enum.each(&ConcurrentLimiter.new(&1, 1, 0)) end + + @spec steal_emoji_policy_setup() :: :ok + defp steal_emoji_policy_setup() do + with true <- + Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy in Config.get!([:mrf, :policies]) do + path = + [:instance, :static_dir] + |> Config.get!() + |> Path.join("emoji/steal") + + if !File.exists?(path), do: File.mkdir_p!(path) + else + _ -> + :ok + end + end end