summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2024-01-20 18:22:49 -0500
committerMark Felder <feld@feld.me>2024-01-20 18:43:53 -0500
commitc7eda0b24ade372e4e167ae560a2debb555a6e02 (patch)
tree3e0a2f034750295bdb4e2c8888547209e5c74969 /lib
parent029aaf3d744184737666b1e553ed92d7708f1fee (diff)
downloadpleroma-c7eda0b24ade372e4e167ae560a2debb555a6e02.tar.gz
pleroma-c7eda0b24ade372e4e167ae560a2debb555a6e02.zip
Use config to control loading of custom modules
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/application.ex34
-rw-r--r--lib/pleroma/user.ex3
-rw-r--r--lib/pleroma/web/o_auth/token.ex3
3 files changed, 20 insertions, 20 deletions
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index a01a13b18..de7d06974 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -106,7 +106,7 @@ defmodule Pleroma.Application do
{Oban, Config.get(Oban)},
Pleroma.Web.Endpoint
] ++
- task_children(@mix_env) ++
+ task_children() ++
dont_run_in_test(@mix_env) ++
shout_child(shout_enabled?()) ++
[Pleroma.Gopher.Server]
@@ -154,7 +154,7 @@ defmodule Pleroma.Application do
raise "Invalid custom modules"
{:ok, modules, _warnings} ->
- if @mix_env != :test do
+ if Application.get_env(:pleroma, __MODULE__)[:load_custom_modules] do
Enum.each(modules, fn mod ->
Logger.info("Custom module loaded: #{inspect(mod)}")
end)
@@ -237,29 +237,27 @@ defmodule Pleroma.Application do
defp shout_child(_), do: []
- defp task_children(:test) do
- [
+ defp task_children() do
+ children = [
%{
id: :web_push_init,
start: {Task, :start_link, [&Pleroma.Web.Push.init/0]},
restart: :temporary
}
]
- end
- defp task_children(_) do
- [
- %{
- id: :web_push_init,
- start: {Task, :start_link, [&Pleroma.Web.Push.init/0]},
- restart: :temporary
- },
- %{
- id: :internal_fetch_init,
- start: {Task, :start_link, [&Pleroma.Web.ActivityPub.InternalFetchActor.init/0]},
- restart: :temporary
- }
- ]
+ if Application.get_env(:pleroma, __MODULE__)[:internal_fetch] do
+ children ++
+ [
+ %{
+ id: :internal_fetch_init,
+ start: {Task, :start_link, [&Pleroma.Web.ActivityPub.InternalFetchActor.init/0]},
+ restart: :temporary
+ }
+ ]
+ else
+ children
+ end
end
# start hackney and gun pools in tests
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index ac049ec17..89a95c435 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -1048,7 +1048,8 @@ defmodule Pleroma.User do
def needs_update?(_), do: true
- @spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t(), User.t()} | {:error, String.t()}
+ @spec maybe_direct_follow(User.t(), User.t()) ::
+ {:ok, User.t(), User.t()} | {:error, String.t()}
# "Locked" (self-locked) users demand explicit authorization of follow requests
def maybe_direct_follow(%User{} = follower, %User{local: true, is_locked: true} = followed) do
diff --git a/lib/pleroma/web/o_auth/token.ex b/lib/pleroma/web/o_auth/token.ex
index 4369b3164..d4a7e8999 100644
--- a/lib/pleroma/web/o_auth/token.ex
+++ b/lib/pleroma/web/o_auth/token.ex
@@ -56,7 +56,8 @@ defmodule Pleroma.Web.OAuth.Token do
|> Repo.find_resource()
end
- @spec exchange_token(App.t(), Authorization.t()) :: {:ok, Token.t()} | {:error, Ecto.Changeset.t()}
+ @spec exchange_token(App.t(), Authorization.t()) ::
+ {:ok, Token.t()} | {:error, Ecto.Changeset.t()}
def exchange_token(app, auth) do
with {:ok, auth} <- Authorization.use_token(auth),
true <- auth.app_id == app.id do