Use config to control loading of custom modules
This commit is contained in:
parent
029aaf3d74
commit
c7eda0b24a
|
@ -905,6 +905,8 @@
|
||||||
initial_indexing_chunk_size: 100_000
|
initial_indexing_chunk_size: 100_000
|
||||||
|
|
||||||
config :pleroma, Pleroma.Application,
|
config :pleroma, Pleroma.Application,
|
||||||
|
internal_fetch: true,
|
||||||
|
load_custom_modules: true,
|
||||||
max_restarts: 3
|
max_restarts: 3
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
|
|
|
@ -162,7 +162,10 @@
|
||||||
|
|
||||||
config :pleroma, Pleroma.Cluster, peer_module: peer_module
|
config :pleroma, Pleroma.Cluster, peer_module: peer_module
|
||||||
|
|
||||||
config :pleroma, Pleroma.Application, max_restarts: 100
|
config :pleroma, Pleroma.Application,
|
||||||
|
internal_fetch: false,
|
||||||
|
load_custom_modules: false,
|
||||||
|
max_restarts: 100
|
||||||
|
|
||||||
if File.exists?("./config/test.secret.exs") do
|
if File.exists?("./config/test.secret.exs") do
|
||||||
import_config "test.secret.exs"
|
import_config "test.secret.exs"
|
||||||
|
|
|
@ -106,7 +106,7 @@ def start(_type, _args) do
|
||||||
{Oban, Config.get(Oban)},
|
{Oban, Config.get(Oban)},
|
||||||
Pleroma.Web.Endpoint
|
Pleroma.Web.Endpoint
|
||||||
] ++
|
] ++
|
||||||
task_children(@mix_env) ++
|
task_children() ++
|
||||||
dont_run_in_test(@mix_env) ++
|
dont_run_in_test(@mix_env) ++
|
||||||
shout_child(shout_enabled?()) ++
|
shout_child(shout_enabled?()) ++
|
||||||
[Pleroma.Gopher.Server]
|
[Pleroma.Gopher.Server]
|
||||||
|
@ -154,7 +154,7 @@ def load_custom_modules do
|
||||||
raise "Invalid custom modules"
|
raise "Invalid custom modules"
|
||||||
|
|
||||||
{:ok, modules, _warnings} ->
|
{:ok, modules, _warnings} ->
|
||||||
if @mix_env != :test do
|
if Application.get_env(:pleroma, __MODULE__)[:load_custom_modules] do
|
||||||
Enum.each(modules, fn mod ->
|
Enum.each(modules, fn mod ->
|
||||||
Logger.info("Custom module loaded: #{inspect(mod)}")
|
Logger.info("Custom module loaded: #{inspect(mod)}")
|
||||||
end)
|
end)
|
||||||
|
@ -237,29 +237,27 @@ defp shout_child(true) do
|
||||||
|
|
||||||
defp shout_child(_), do: []
|
defp shout_child(_), do: []
|
||||||
|
|
||||||
defp task_children(:test) do
|
defp task_children() do
|
||||||
[
|
children = [
|
||||||
%{
|
%{
|
||||||
id: :web_push_init,
|
id: :web_push_init,
|
||||||
start: {Task, :start_link, [&Pleroma.Web.Push.init/0]},
|
start: {Task, :start_link, [&Pleroma.Web.Push.init/0]},
|
||||||
restart: :temporary
|
restart: :temporary
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
end
|
|
||||||
|
|
||||||
defp task_children(_) do
|
if Application.get_env(:pleroma, __MODULE__)[:internal_fetch] do
|
||||||
[
|
children ++
|
||||||
%{
|
[
|
||||||
id: :web_push_init,
|
%{
|
||||||
start: {Task, :start_link, [&Pleroma.Web.Push.init/0]},
|
id: :internal_fetch_init,
|
||||||
restart: :temporary
|
start: {Task, :start_link, [&Pleroma.Web.ActivityPub.InternalFetchActor.init/0]},
|
||||||
},
|
restart: :temporary
|
||||||
%{
|
}
|
||||||
id: :internal_fetch_init,
|
]
|
||||||
start: {Task, :start_link, [&Pleroma.Web.ActivityPub.InternalFetchActor.init/0]},
|
else
|
||||||
restart: :temporary
|
children
|
||||||
}
|
end
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# start hackney and gun pools in tests
|
# start hackney and gun pools in tests
|
||||||
|
|
|
@ -1048,7 +1048,8 @@ def needs_update?(%User{local: false} = user) do
|
||||||
|
|
||||||
def needs_update?(_), do: true
|
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
|
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
||||||
def maybe_direct_follow(%User{} = follower, %User{local: true, is_locked: true} = followed) do
|
def maybe_direct_follow(%User{} = follower, %User{local: true, is_locked: true} = followed) do
|
||||||
|
|
|
@ -56,7 +56,8 @@ def get_by_refresh_token(%App{id: app_id} = _app, token) do
|
||||||
|> Repo.find_resource()
|
|> Repo.find_resource()
|
||||||
end
|
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
|
def exchange_token(app, auth) do
|
||||||
with {:ok, auth} <- Authorization.use_token(auth),
|
with {:ok, auth} <- Authorization.use_token(auth),
|
||||||
true <- auth.app_id == app.id do
|
true <- auth.app_id == app.id do
|
||||||
|
|
Loading…
Reference in New Issue