From 2fdfed50f0621179b525b9b917db2789fad67602 Mon Sep 17 00:00:00 2001 From: sadposter Date: Tue, 15 Aug 2023 22:09:10 +0100 Subject: [PATCH] Ensure scrubbers are loaded by the compiler --- lib/mix/pleroma.ex | 2 ++ lib/mix/tasks/pleroma/diagnostics.ex | 7 +++++++ lib/pleroma/application.ex | 1 - lib/pleroma/html.ex | 14 -------------- {priv => lib/pleroma/html}/scrubbers/default.ex | 0 {priv => lib/pleroma/html}/scrubbers/links_only.ex | 0 .../pleroma/html}/scrubbers/media_proxy.ex | 0 .../pleroma/html}/scrubbers/twitter_text.ex | 0 8 files changed, 9 insertions(+), 15 deletions(-) rename {priv => lib/pleroma/html}/scrubbers/default.ex (100%) rename {priv => lib/pleroma/html}/scrubbers/links_only.ex (100%) rename {priv => lib/pleroma/html}/scrubbers/media_proxy.ex (100%) rename {priv => lib/pleroma/html}/scrubbers/twitter_text.ex (100%) diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex index 6431f0a1c..f99e8ee96 100644 --- a/lib/mix/pleroma.ex +++ b/lib/mix/pleroma.ex @@ -39,6 +39,8 @@ def start_pleroma do Enum.each(@apps, &Application.ensure_all_started/1) + Pleroma.Application.load_all_pleroma_modules() + oban_config = [ crontab: [], repo: Pleroma.Repo, diff --git a/lib/mix/tasks/pleroma/diagnostics.ex b/lib/mix/tasks/pleroma/diagnostics.ex index 87be38b78..51c2bc044 100644 --- a/lib/mix/tasks/pleroma/diagnostics.ex +++ b/lib/mix/tasks/pleroma/diagnostics.ex @@ -17,6 +17,13 @@ def run(["http", url]) do |> IO.inspect() end + def run(["get_object", url]) do + start_pleroma() + + Pleroma.Object.Fetcher.fetch_object_from_id(url) + |> IO.inspect() + end + def run(["home_timeline", nickname]) do start_pleroma() user = Repo.get_by!(User, nickname: nickname) diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 3200175d1..4f4098127 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -48,7 +48,6 @@ def start(_type, _args) do # due to protocol consolidation warnings Code.compiler_options(warnings_as_errors: false) Config.Holder.save_default() - Pleroma.HTML.compile_scrubbers() Pleroma.Config.Oban.warn() Config.DeprecationWarnings.warn() Pleroma.Web.Plugs.HTTPSecurityPlug.warn_if_disabled() diff --git a/lib/pleroma/html.ex b/lib/pleroma/html.ex index bee66169d..a43f88d92 100644 --- a/lib/pleroma/html.ex +++ b/lib/pleroma/html.ex @@ -8,20 +8,6 @@ defmodule Pleroma.HTML do @cachex Pleroma.Config.get([:cachex, :provider], Cachex) - def compile_scrubbers do - dir = Path.join(:code.priv_dir(:pleroma), "scrubbers") - - dir - |> Pleroma.Utils.compile_dir() - |> case do - {:error, _errors, _warnings} -> - raise "Compiling scrubbers failed" - - {:ok, _modules, _warnings} -> - :ok - end - end - defp get_scrubbers(scrubber) when is_atom(scrubber), do: [scrubber] defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default] diff --git a/priv/scrubbers/default.ex b/lib/pleroma/html/scrubbers/default.ex similarity index 100% rename from priv/scrubbers/default.ex rename to lib/pleroma/html/scrubbers/default.ex diff --git a/priv/scrubbers/links_only.ex b/lib/pleroma/html/scrubbers/links_only.ex similarity index 100% rename from priv/scrubbers/links_only.ex rename to lib/pleroma/html/scrubbers/links_only.ex diff --git a/priv/scrubbers/media_proxy.ex b/lib/pleroma/html/scrubbers/media_proxy.ex similarity index 100% rename from priv/scrubbers/media_proxy.ex rename to lib/pleroma/html/scrubbers/media_proxy.ex diff --git a/priv/scrubbers/twitter_text.ex b/lib/pleroma/html/scrubbers/twitter_text.ex similarity index 100% rename from priv/scrubbers/twitter_text.ex rename to lib/pleroma/html/scrubbers/twitter_text.ex